mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Make transfer dialog modeless.
account-tree.[ch]: change 'category' to 'income_expense'
AccWindow.h: remove notes window functions, this was only a separate
window in Motif
Destroy.c: remove notes window functions
dialog-add.c: remove notes window functions
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2603 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
2000-07-20 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/gnome/top-level.c (gnc_ui_destroy_all_subwindows): destroy
|
||||
open transfer windows.
|
||||
|
||||
* src/Destroy.c: remove notes window functions.
|
||||
|
||||
* src/AccWindow.h: remove notes window functions.
|
||||
|
||||
* src/gnome/dialog-transfer.c: Make transfer dialog modeless.
|
||||
|
||||
2000-07-19 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/gnome/account-tree.c: Use income_expense instead of
|
||||
category for names.
|
||||
|
||||
2000-07-12 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/SplitLedger.c (LedgerAutoCompletion): simplify, and fix a
|
||||
|
||||
+5
-8
@@ -1,7 +1,7 @@
|
||||
/********************************************************************\
|
||||
* AccWindow.h -- window for creating new accounts for xacc *
|
||||
* (X-Accountant) *
|
||||
* AccWindow.h -- window for creating new accounts for GnuCash *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@@ -23,8 +23,8 @@
|
||||
* Huntington Beach, CA 92648-4632 *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef __XACC_NEWACCWINDOW_H__
|
||||
#define __XACC_NEWACCWINDOW_H__
|
||||
#ifndef __ACC_WINDOW_H__
|
||||
#define __ACC_WINDOW_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -34,11 +34,9 @@
|
||||
/** PROTOTYPES ******************************************************/
|
||||
typedef struct _accwindow AccWindow;
|
||||
typedef struct _editaccwindow EditAccWindow;
|
||||
typedef struct _editnoteswindow EditNotesWindow;
|
||||
|
||||
AccWindow * accWindow( AccountGroup *grp);
|
||||
EditAccWindow * editAccWindow( Account *account );
|
||||
EditNotesWindow * editNotesWindow (Account *acc);
|
||||
|
||||
|
||||
/*
|
||||
@@ -47,10 +45,9 @@ EditNotesWindow * editNotesWindow (Account *acc);
|
||||
* destroying the underlying account.
|
||||
*/
|
||||
void xaccDestroyEditAccWindow (Account *);
|
||||
void xaccDestroyEditNotesWindow (Account *);
|
||||
|
||||
void editAccountRefresh(Account *);
|
||||
|
||||
void xaccSetDefaultNewaccountCurrency(char *new_default_currency);
|
||||
|
||||
#endif /* __XACC_NEWACCWINDOW_H__ */
|
||||
#endif /* __ACC_WINDOW_H__ */
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************\
|
||||
* Destroy.c -- utilities for the window destruction (X-Accountant) *
|
||||
/********************************************************************\
|
||||
* Destroy.c -- utilities for the window destruction GnuCash *
|
||||
* Copyright (C) 1997 Linas Vepstas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@@ -40,7 +40,6 @@ xaccAccountWindowDestroySimple (Account *acc)
|
||||
xaccDestroyRecnWindow (acc);
|
||||
xaccDestroyAdjBWindow (acc);
|
||||
xaccDestroyEditAccWindow (acc);
|
||||
xaccDestroyEditNotesWindow (acc);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
@@ -589,14 +589,14 @@ gnc_account_tree_insert_account(GNCAccountTree *tree, Account *account)
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_account_tree_show_categories *
|
||||
* gnc_account_tree_show_income_expense *
|
||||
* shows the income/expense accounts in a tree *
|
||||
* *
|
||||
* Args: tree - tree to show income/expense accounts *
|
||||
* Returns: nothing *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_account_tree_show_categories(GNCAccountTree *tree)
|
||||
gnc_account_tree_show_income_expense(GNCAccountTree *tree)
|
||||
{
|
||||
tree->avi.include_type[EXPENSE] = GNC_T;
|
||||
tree->avi.include_type[INCOME] = GNC_T;
|
||||
@@ -606,14 +606,14 @@ gnc_account_tree_show_categories(GNCAccountTree *tree)
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_account_tree_hide_categories *
|
||||
* gnc_account_tree_hide_income_expense *
|
||||
* hides the income/expense accounts in a tree *
|
||||
* *
|
||||
* Args: tree - tree to hide income/expense accounts *
|
||||
* Returns: nothing *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_account_tree_hide_categories(GNCAccountTree *tree)
|
||||
gnc_account_tree_hide_income_expense(GNCAccountTree *tree)
|
||||
{
|
||||
tree->avi.include_type[EXPENSE] = GNC_F;
|
||||
tree->avi.include_type[INCOME] = GNC_F;
|
||||
|
||||
@@ -129,9 +129,9 @@ void gnc_account_tree_remove_account (GNCAccountTree *tree,
|
||||
|
||||
void gnc_account_tree_remove_account_all(Account *account);
|
||||
|
||||
void gnc_account_tree_show_categories (GNCAccountTree *tree);
|
||||
void gnc_account_tree_show_income_expense (GNCAccountTree *tree);
|
||||
|
||||
void gnc_account_tree_hide_categories (GNCAccountTree *tree);
|
||||
void gnc_account_tree_hide_income_expense (GNCAccountTree *tree);
|
||||
|
||||
Account * gnc_account_tree_get_current_account (GNCAccountTree *tree);
|
||||
GList * gnc_account_tree_get_current_accounts (GNCAccountTree *tree);
|
||||
|
||||
@@ -639,13 +639,6 @@ accWindow (AccountGroup *this_is_not_used)
|
||||
}
|
||||
|
||||
|
||||
/* This is a no-op for the gnome code */
|
||||
void
|
||||
xaccDestroyEditNotesWindow (Account *acc)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************\
|
||||
* xaccSetDefaultNewaccountCurrency *
|
||||
* Set the default currency for new accounts *
|
||||
|
||||
+261
-136
@@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* dialog-transfer.c -- transfer dialog for GnuCash *
|
||||
* Copyright (C) 1999 Linas Vepstas *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@@ -38,13 +39,22 @@
|
||||
#include "util.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XFER_DIALOG_FROM,
|
||||
XFER_DIALOG_TO
|
||||
} XferDirection;
|
||||
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
typedef struct _xferDialog XferDialog;
|
||||
static GList *xfer_dialogs = NULL;
|
||||
|
||||
struct _xferDialog
|
||||
{
|
||||
GtkWidget * dialog;
|
||||
|
||||
GtkWidget * amount_entry;
|
||||
GtkWidget * date_entry;
|
||||
GtkWidget * description_entry;
|
||||
@@ -52,6 +62,9 @@ struct _xferDialog
|
||||
|
||||
GNCAccountTree * from;
|
||||
GNCAccountTree * to;
|
||||
|
||||
GtkWidget * from_show_button;
|
||||
GtkWidget * to_show_button;
|
||||
};
|
||||
|
||||
|
||||
@@ -61,20 +74,19 @@ gnc_xfer_dialog_toggle_cb(GtkToggleButton *button, gpointer data)
|
||||
GNCAccountTree *tree = GNC_ACCOUNT_TREE(data);
|
||||
|
||||
if (gtk_toggle_button_get_active(button))
|
||||
gnc_account_tree_show_categories(tree);
|
||||
gnc_account_tree_show_income_expense(tree);
|
||||
else
|
||||
gnc_account_tree_hide_categories(tree);
|
||||
gnc_account_tree_hide_income_expense(tree);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
gnc_xfer_dialog_create_tree_frame(Account *initial, gchar *title,
|
||||
GNCAccountTree **set_tree,
|
||||
gnc_xfer_dialog_create_tree_frame(gchar *title,
|
||||
GNCAccountTree **set_tree,
|
||||
GtkWidget **set_show_button,
|
||||
GtkTooltips *tooltips)
|
||||
{
|
||||
GtkWidget *frame, *scrollWin, *accountTree, *vbox, *button;
|
||||
gboolean is_category;
|
||||
int type;
|
||||
|
||||
frame = gtk_frame_new(title);
|
||||
|
||||
@@ -82,15 +94,11 @@ gnc_xfer_dialog_create_tree_frame(Account *initial, gchar *title,
|
||||
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
|
||||
|
||||
type = xaccAccountGetType(initial);
|
||||
is_category = (type == EXPENSE) || (type == INCOME);
|
||||
|
||||
accountTree = gnc_account_tree_new();
|
||||
*set_tree = GNC_ACCOUNT_TREE(accountTree);
|
||||
gtk_clist_column_titles_hide(GTK_CLIST(accountTree));
|
||||
gnc_account_tree_hide_all_but_name(GNC_ACCOUNT_TREE(accountTree));
|
||||
if (!is_category)
|
||||
gnc_account_tree_hide_categories(GNC_ACCOUNT_TREE(accountTree));
|
||||
gnc_account_tree_hide_income_expense(GNC_ACCOUNT_TREE(accountTree));
|
||||
gnc_account_tree_refresh(GNC_ACCOUNT_TREE(accountTree));
|
||||
|
||||
scrollWin = gtk_scrolled_window_new (NULL, NULL);
|
||||
@@ -117,13 +125,13 @@ gnc_xfer_dialog_create_tree_frame(Account *initial, gchar *title,
|
||||
}
|
||||
|
||||
button = gtk_check_button_new_with_label(SHOW_INC_EXP_STR);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), is_category);
|
||||
*set_show_button = button;
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
|
||||
gtk_tooltips_set_tip(tooltips, button, SHOW_INC_EXP_MSG, NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(button), "toggled",
|
||||
GTK_SIGNAL_FUNC(gnc_xfer_dialog_toggle_cb),
|
||||
(gpointer) accountTree);
|
||||
GTK_SIGNAL_FUNC(gnc_xfer_dialog_toggle_cb), accountTree);
|
||||
|
||||
return frame;
|
||||
}
|
||||
@@ -164,9 +172,184 @@ gnc_xfer_update_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
gnc_xfer_dialog_create(GtkWidget * parent, Account * initial,
|
||||
XferDialog *xferData)
|
||||
static void
|
||||
gnc_xfer_dialog_select_account(XferDialog *xferData, Account *account,
|
||||
XferDirection direction)
|
||||
{
|
||||
GNCAccountTree *tree;
|
||||
GtkWidget *show_button;
|
||||
gboolean is_income_expense;
|
||||
GNCAccountType type;
|
||||
|
||||
if (xferData == NULL)
|
||||
return;
|
||||
if (account == NULL)
|
||||
return;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case XFER_DIALOG_FROM:
|
||||
tree = xferData->from;
|
||||
show_button = xferData->from_show_button;
|
||||
break;
|
||||
case XFER_DIALOG_TO:
|
||||
tree = xferData->to;
|
||||
show_button = xferData->to_show_button;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
type = xaccAccountGetType(account);
|
||||
is_income_expense = (type == EXPENSE) || (type == INCOME);
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_button),
|
||||
is_income_expense);
|
||||
|
||||
gnc_account_tree_select_account(tree, account, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_xfer_dialog_select_from_account *
|
||||
* select the from account in a xfer dialog *
|
||||
* *
|
||||
* Args: xferData - xfer dialog structure *
|
||||
* account - account to select *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_xfer_dialog_select_from_account(XferDialog *xferData, Account *account)
|
||||
{
|
||||
gnc_xfer_dialog_select_account(xferData, account, XFER_DIALOG_FROM);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_xfer_dialog_select_to_account *
|
||||
* select the to account in a xfer dialog *
|
||||
* *
|
||||
* Args: xferData - xfer dialog structure *
|
||||
* account - account to select *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_xfer_dialog_select_to_account(XferDialog *xferData, Account *account)
|
||||
{
|
||||
gnc_xfer_dialog_select_account(xferData, account, XFER_DIALOG_TO);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_xfer_dialog_ok_cb(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
XferDialog *xferData = data;
|
||||
Account *from, *to;
|
||||
char * string;
|
||||
double amount;
|
||||
time_t time;
|
||||
|
||||
Transaction *trans;
|
||||
Split *from_split;
|
||||
Split *to_split;
|
||||
|
||||
|
||||
from = gnc_account_tree_get_current_account(xferData->from);
|
||||
to = gnc_account_tree_get_current_account(xferData->to);
|
||||
|
||||
if ((from == NULL) || (to == NULL))
|
||||
{
|
||||
gnc_error_dialog_parented(GTK_WINDOW(xferData->dialog), XFER_NO_ACC_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
if (from == to)
|
||||
{
|
||||
gnc_error_dialog_parented(GTK_WINDOW(xferData->dialog), XFER_SAME_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xaccAccountsHaveCommonCurrency(from, to))
|
||||
{
|
||||
gnc_error_dialog_parented(GTK_WINDOW(xferData->dialog), XFER_CURR_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
string = gtk_entry_get_text(GTK_ENTRY(xferData->amount_entry));
|
||||
amount = xaccParseAmount(string, GNC_T);
|
||||
|
||||
time = gnc_date_edit_get_date(GNC_DATE_EDIT(xferData->date_entry));
|
||||
|
||||
/* Create the transaction */
|
||||
trans = xaccMallocTransaction();
|
||||
|
||||
xaccTransBeginEdit(trans, GNC_T);
|
||||
xaccTransSetDateSecs(trans, time);
|
||||
|
||||
string = gtk_entry_get_text(GTK_ENTRY(xferData->description_entry));
|
||||
xaccTransSetDescription(trans, string);
|
||||
|
||||
/* first split is already there */
|
||||
to_split = xaccTransGetSplit(trans, 0);
|
||||
xaccSplitSetShareAmount(to_split, amount);
|
||||
|
||||
/* second split must be created */
|
||||
from_split = xaccMallocSplit();
|
||||
xaccSplitSetShareAmount(from_split, -amount);
|
||||
xaccTransAppendSplit(trans, from_split);
|
||||
|
||||
/* TransSetMemo will set the memo for both splits */
|
||||
string = gtk_entry_get_text(GTK_ENTRY(xferData->memo_entry));
|
||||
xaccTransSetMemo(trans, string);
|
||||
|
||||
/* Now do the 'to' account */
|
||||
xaccAccountBeginEdit(to, GNC_F);
|
||||
xaccAccountInsertSplit(to, to_split);
|
||||
xaccAccountCommitEdit(to);
|
||||
|
||||
/* Now do the 'from' account */
|
||||
xaccAccountBeginEdit(from, GNC_F);
|
||||
xaccAccountInsertSplit(from, from_split);
|
||||
xaccAccountCommitEdit(from);
|
||||
|
||||
/* finish transaction */
|
||||
xaccTransCommitEdit(trans);
|
||||
|
||||
/* Refresh everything */
|
||||
gnc_account_ui_refresh(to);
|
||||
gnc_account_ui_refresh(from);
|
||||
gnc_refresh_main_window();
|
||||
|
||||
gnome_dialog_close(GNOME_DIALOG(xferData->dialog));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_xfer_dialog_cancel_cb(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
XferDialog *xferData = data;
|
||||
|
||||
gnome_dialog_close(GNOME_DIALOG(xferData->dialog));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
gnc_xfer_dialog_close_cb(GnomeDialog *dialog, gpointer data)
|
||||
{
|
||||
XferDialog * xferData = data;
|
||||
|
||||
xfer_dialogs = g_list_remove(xfer_dialogs, dialog);
|
||||
|
||||
g_free(xferData);
|
||||
|
||||
DEBUG("xfer dialog destroyed\n");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_xfer_dialog_create(GtkWidget * parent, XferDialog *xferData)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkTooltips *tooltips;
|
||||
@@ -178,17 +361,29 @@ gnc_xfer_dialog_create(GtkWidget * parent, Account * initial,
|
||||
|
||||
xferData->dialog = dialog;
|
||||
|
||||
/* Make this dialog modal */
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
|
||||
/* parent */
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(parent));
|
||||
if (parent != NULL)
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(parent));
|
||||
|
||||
/* default to ok */
|
||||
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
|
||||
|
||||
/* don't close on buttons */
|
||||
gnome_dialog_set_close(GNOME_DIALOG(dialog), FALSE);
|
||||
/* destroy on close */
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE);
|
||||
|
||||
/* allow grow and shrink, no auto-shrink */
|
||||
gtk_window_set_policy(GTK_WINDOW(dialog), TRUE, TRUE, FALSE);
|
||||
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(dialog), 0,
|
||||
GTK_SIGNAL_FUNC(gnc_xfer_dialog_ok_cb),
|
||||
xferData);
|
||||
|
||||
gnome_dialog_button_connect(GNOME_DIALOG(dialog), 1,
|
||||
GTK_SIGNAL_FUNC(gnc_xfer_dialog_cancel_cb),
|
||||
xferData);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(dialog), "close",
|
||||
GTK_SIGNAL_FUNC(gnc_xfer_dialog_close_cb), xferData);
|
||||
|
||||
tooltips = gtk_tooltips_new();
|
||||
|
||||
@@ -291,139 +486,69 @@ gnc_xfer_dialog_create(GtkWidget * parent, Account * initial,
|
||||
gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox),
|
||||
hbox, TRUE, TRUE, 0);
|
||||
|
||||
tree = gnc_xfer_dialog_create_tree_frame(initial, XFRM_STR,
|
||||
&xferData->from, tooltips);
|
||||
tree = gnc_xfer_dialog_create_tree_frame(XFRM_STR,
|
||||
&xferData->from,
|
||||
&xferData->from_show_button,
|
||||
tooltips);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), tree, TRUE, TRUE, 0);
|
||||
|
||||
tree = gnc_xfer_dialog_create_tree_frame(initial, XFTO_STR,
|
||||
&xferData->to, tooltips);
|
||||
tree = gnc_xfer_dialog_create_tree_frame(XFTO_STR,
|
||||
&xferData->to,
|
||||
&xferData->to_show_button,
|
||||
tooltips);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), tree, TRUE, TRUE, 0);
|
||||
}
|
||||
|
||||
/* allow grow and shrink, no auto-shrink */
|
||||
gtk_window_set_policy(GTK_WINDOW(dialog), TRUE, TRUE, FALSE);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* xferWindow *
|
||||
* gnc_xfer_dialog *
|
||||
* opens up a window to do an automatic transfer between accounts *
|
||||
* *
|
||||
* Args: parent - the parent of the window to be created *
|
||||
* initial - the initial account in the from/to fields *
|
||||
* group - the group from which the accounts are taken *
|
||||
* Return: none *
|
||||
* Return: XferDialog structure *
|
||||
\********************************************************************/
|
||||
void
|
||||
XferDialog *
|
||||
gnc_xfer_dialog(GtkWidget * parent, Account * initial)
|
||||
{
|
||||
Account *from, *to;
|
||||
GtkWidget *dialog;
|
||||
XferDialog xferData;
|
||||
char * string;
|
||||
double amount;
|
||||
time_t time;
|
||||
gint result;
|
||||
XferDialog *xferData;
|
||||
|
||||
if (xaccGroupGetNumAccounts(gncGetCurrentGroup()) < 2)
|
||||
{
|
||||
gnc_error_dialog(XFER_NSF_MSG);
|
||||
return;
|
||||
}
|
||||
xferData = g_new0(XferDialog, 1);
|
||||
|
||||
dialog = gnc_xfer_dialog_create(parent, initial, &xferData);
|
||||
gnc_xfer_dialog_create(parent, xferData);
|
||||
|
||||
gtk_widget_show_all(dialog);
|
||||
xfer_dialogs = g_list_prepend(xfer_dialogs, xferData->dialog);
|
||||
|
||||
gtk_widget_grab_focus(xferData.amount_entry);
|
||||
gtk_widget_grab_focus(xferData->amount_entry);
|
||||
|
||||
gnc_account_tree_select_account(xferData.from, initial, TRUE);
|
||||
gnc_account_tree_select_account(xferData.to, initial, TRUE);
|
||||
gnc_xfer_dialog_select_from_account(xferData, initial);
|
||||
gnc_xfer_dialog_select_to_account(xferData, initial);
|
||||
|
||||
while (1)
|
||||
{
|
||||
result = gnome_dialog_run(GNOME_DIALOG(dialog));
|
||||
gtk_widget_show_all(xferData->dialog);
|
||||
|
||||
if (result != 0)
|
||||
break;
|
||||
gnc_window_adjust_for_screen(GTK_WINDOW(xferData->dialog));
|
||||
|
||||
from = gnc_account_tree_get_current_account(xferData.from);
|
||||
to = gnc_account_tree_get_current_account(xferData.to);
|
||||
|
||||
if ((from == NULL) || (to == NULL))
|
||||
{
|
||||
gnc_error_dialog_parented(GTK_WINDOW(dialog), XFER_NO_ACC_MSG);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (from == to)
|
||||
{
|
||||
gnc_error_dialog_parented(GTK_WINDOW(dialog), XFER_SAME_MSG);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!xaccAccountsHaveCommonCurrency(from, to))
|
||||
{
|
||||
gnc_error_dialog_parented(GTK_WINDOW(dialog), XFER_CURR_MSG);
|
||||
continue;
|
||||
}
|
||||
|
||||
string = gtk_entry_get_text(GTK_ENTRY(xferData.amount_entry));
|
||||
amount = xaccParseAmount(string, GNC_T);
|
||||
|
||||
time = gnc_date_edit_get_date(GNC_DATE_EDIT(xferData.date_entry));
|
||||
|
||||
{
|
||||
Transaction *trans;
|
||||
Split *to_split, *from_split;
|
||||
|
||||
/* Create the transaction */
|
||||
trans = xaccMallocTransaction();
|
||||
|
||||
xaccTransBeginEdit(trans, GNC_T);
|
||||
xaccTransSetDateSecs(trans, time);
|
||||
|
||||
string = gtk_entry_get_text(GTK_ENTRY(xferData.description_entry));
|
||||
xaccTransSetDescription(trans, string);
|
||||
|
||||
/* first split is already there */
|
||||
to_split = xaccTransGetSplit(trans, 0);
|
||||
xaccSplitSetShareAmount(to_split, amount);
|
||||
|
||||
/* second split must be created */
|
||||
from_split = xaccMallocSplit();
|
||||
xaccSplitSetShareAmount(from_split, -amount);
|
||||
xaccTransAppendSplit(trans, from_split);
|
||||
|
||||
/* TransSetMemo will set the memo for both splits */
|
||||
string = gtk_entry_get_text(GTK_ENTRY(xferData.memo_entry));
|
||||
xaccTransSetMemo(trans, string);
|
||||
|
||||
/* Now do the 'to' account */
|
||||
xaccAccountBeginEdit(to, GNC_F);
|
||||
xaccAccountInsertSplit(to, to_split);
|
||||
xaccAccountCommitEdit(to);
|
||||
|
||||
/* Now do the 'from' account */
|
||||
xaccAccountBeginEdit(from, GNC_F);
|
||||
xaccAccountInsertSplit(from, from_split);
|
||||
xaccAccountCommitEdit(from);
|
||||
|
||||
/* finish transaction */
|
||||
xaccTransCommitEdit(trans);
|
||||
|
||||
/* Refresh everything */
|
||||
gnc_account_ui_refresh(to);
|
||||
gnc_account_ui_refresh(from);
|
||||
gnc_refresh_main_window();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG("destroying transfer dialog\n");
|
||||
|
||||
gtk_widget_destroy(dialog);
|
||||
return xferData;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_ui_destroy_xfer_windows *
|
||||
* destroy all open transfer dialogs *
|
||||
* *
|
||||
* Args: none *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_ui_destroy_xfer_windows()
|
||||
{
|
||||
GnomeDialog *dialog;
|
||||
|
||||
while (xfer_dialogs != NULL)
|
||||
{
|
||||
dialog = GNOME_DIALOG(xfer_dialogs->data);
|
||||
|
||||
gnome_dialog_close(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* dialog-transfer.h -- transfer dialog for GnuCash *
|
||||
* Copyright (C) 1999 Linas Vepstas *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@@ -23,6 +24,10 @@
|
||||
#ifndef __DIALOG_TRANSFER_H__
|
||||
#define __DIALOG_TRANSFER_H__
|
||||
|
||||
void gnc_xfer_dialog(GtkWidget * parent, Account * initial);
|
||||
typedef struct _xferDialog XferDialog;
|
||||
|
||||
XferDialog * gnc_xfer_dialog(GtkWidget * parent, Account *initial);
|
||||
|
||||
void gnc_ui_destroy_xfer_windows();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "gnome-top-level.h"
|
||||
#include "window-main.h"
|
||||
#include "dialog-add.h"
|
||||
#include "dialog-transfer.h"
|
||||
#include "global-options.h"
|
||||
#include "gnucash-sheet.h"
|
||||
#include "gnucash-color.h"
|
||||
@@ -253,6 +254,7 @@ gnc_ui_destroy_all_subwindows (void)
|
||||
gnc_ui_destroy_help_windows();
|
||||
gnc_ui_destroy_report_windows();
|
||||
gnc_ui_destroy_account_add_windows();
|
||||
gnc_ui_destroy_xfer_windows();
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
Reference in New Issue
Block a user