Remove 'Adjust Balance' window.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2909 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-09-20 09:57:35 +00:00
parent 4e52732ffe
commit f512707921
9 changed files with 0 additions and 479 deletions

View File

@ -1,51 +0,0 @@
/********************************************************************\
* AdjBWindow.h -- the adjust balance window *
* Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1998-2000 Linas Vepstas *
* *
* 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 *
* the License, or (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
* Author: Rob Clark *
* Internet: rclark@cs.hmc.edu *
* Address: 609 8th Street *
* Huntington Beach, CA 92648-4632 *
\********************************************************************/
#ifndef __XACC_ADJBWINDOW_H__
#define __XACC_ADJBWINDOW_H__
#include "config.h"
#include "Account.h"
/*
* The adjBWindow() subroutine creates the "adjust-balance" dialog
* for the indicated account, if that dialog is not already mapped.
* If the dialog already esits, it returns with a no-op.
*
* The adjBRefresh() subroutine refreshes the associated window.
*
* The xaccDestroyAdjBWindow() subroutine can be called from
* anywhere to shut down the Register window. Used primarily when
* destroying the underlying account.
*/
typedef struct _AdjBWindow AdjBWindow;
AdjBWindow *adjBWindow(Account *account);
void adjBRefresh(Account *account);
void xaccDestroyAdjBWindow (Account *);
#endif /* __XACC_ADJBWINDOW_H__ */

View File

@ -22,7 +22,6 @@
#include "Account.h"
#include "AccWindow.h"
#include "AdjBWindow.h"
#include "Destroy.h"
#include "Group.h"
#include "MultiLedger.h"
@ -37,7 +36,6 @@ xaccAccountWindowDestroySimple (Account *account)
{
xaccDestroyLedgerDisplay (account);
xaccDestroyRecnWindow (account);
xaccDestroyAdjBWindow (account);
gnc_ui_destroy_edit_account_window (account);
}

View File

@ -47,7 +47,6 @@ gnucash_SOURCES = \
noinst_HEADERS = \
AccWindow.h \
AdjBWindow.h \
Destroy.h \
EuroUtils.h \
FileBox.h \

View File

@ -25,7 +25,6 @@
#include "Refresh.h"
#include "MultiLedger.h"
#include "RecnWindow.h"
#include "AdjBWindow.h"
#include "AccWindow.h"
#include "util.h"
@ -59,7 +58,6 @@ gnc_account_ui_refresh(Account *account)
xaccAccountDisplayRefresh(account);
recnRefresh(account);
adjBRefresh(account);
gnc_ui_refresh_edit_account_window(account);
}

View File

@ -28,7 +28,6 @@ libgncgnome_a_SOURCES = \
query-user.c \
reconcile-list.c \
top-level.c \
window-adjust.c \
window-help.c \
window-html.c \
window-main.c \

View File

@ -1,352 +0,0 @@
/********************************************************************\
* window-adjust.c -- the adjust balance window *
* Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1998-2000 Linas Vepstas *
* *
* 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 *
* the License, or (at your option) any later version. *
* *
* This program 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 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 "top-level.h"
#include <gnome.h>
#include <time.h>
#include "gnome-top-level.h"
#include "ui-callbacks.h"
#include "MultiLedger.h"
#include "AdjBWindow.h"
#include "Refresh.h"
#include "window-reconcile.h"
#include "dialog-utils.h"
#include "query-user.h"
#include "gnc-dateedit.h"
#include "messages.h"
#include "util.h"
/** STRUCTS *********************************************************/
struct _AdjBWindow
{
Account * account; /* The account that we are adjusting */
GtkWidget * dialog; /* The adjust balance dialog */
GtkWidget * balance_entry; /* Text field, the new balance */
GtkWidget * date_entry; /* Date field, the date for the balance */
};
/** GLOBALS *********************************************************/
static AdjBWindow **adjBList = NULL;
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_GUI;
/** Prototypes ******************************************************/
static void gnc_adjb_set_window_name(AdjBWindow *adjBData);
/********************************************************************\
* adjBRefresh *
* refreshes the adjust balance window *
* *
* Args: account - the account of the window to refresh *
* Return: none *
\********************************************************************/
void
adjBRefresh(Account *account)
{
AdjBWindow *adjBData;
FIND_IN_LIST (AdjBWindow, adjBList, account, account, adjBData);
if (adjBData == NULL)
return;
gnc_adjb_set_window_name(adjBData);
}
static int
gnc_ui_adjBWindow_close_cb(GnomeDialog *dialog, gpointer user_data)
{
AdjBWindow * adjBData = (AdjBWindow *) user_data;
Account *account = adjBData->account;
DEBUG("Closing adjust balance window\n");
REMOVE_FROM_LIST (AdjBWindow, adjBList, account, account);
free(adjBData);
/* really close */
return FALSE;
}
static void
gnc_ui_AdjBWindow_cancel_cb(GtkWidget * widget, gpointer data)
{
AdjBWindow *adjBData = (AdjBWindow *) data;
gnome_dialog_close(GNOME_DIALOG(adjBData->dialog));
}
static void
gnc_ui_AdjBWindow_ok_cb(GtkWidget * widget, gpointer data)
{
AdjBWindow *adjBData = data;
Transaction *trans;
Split *source_split;
double new_balance = 0.0;
double current_balance;
gchar * string;
time_t time;
string = gtk_entry_get_text(GTK_ENTRY(adjBData->balance_entry));
xaccParseAmount(string, TRUE, &new_balance, NULL);
if (gnc_reverse_balance(adjBData->account))
new_balance = -new_balance;
time = gnc_date_edit_get_date(GNC_DATE_EDIT(adjBData->date_entry));
trans = xaccMallocTransaction();
xaccTransBeginEdit(trans, 0);
xaccTransSetDateSecs(trans, time);
xaccTransSetDescription(trans, ADJ_BALN_STR);
source_split = xaccTransGetSplit(trans, 0);
xaccAccountBeginEdit(adjBData->account, 0);
xaccAccountInsertSplit(adjBData->account, source_split);
/* Compute the dollar amount this transaction should have.
* It is the difference between the current balance, and
* the desired balance. */
current_balance = xaccSplitGetBalance(source_split);
xaccSplitSetValue(source_split, new_balance - current_balance);
xaccAccountCommitEdit(adjBData->account);
xaccTransCommitEdit(trans);
gnc_account_ui_refresh(adjBData->account);
gnc_refresh_main_window();
gnome_dialog_close(GNOME_DIALOG(adjBData->dialog));
}
static gboolean
gnc_adjust_update_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
GtkEntry *entry = GTK_ENTRY(widget);
Account *account = data;
const char *new_string;
const char *currency;
const char *string;
double value;
string = gtk_entry_get_text(entry);
value = 0.0;
xaccParseAmount(string, TRUE, &value, NULL);
currency = xaccAccountGetCurrency(account);
new_string = xaccPrintAmount(value, PRTSEP, currency);
if (safe_strcmp(string, new_string) == 0)
return FALSE;
gtk_entry_set_text(entry, new_string);
return FALSE;
}
static char *
gnc_adjb_make_window_name(Account *account)
{
char *fullname;
char *title;
fullname = xaccAccountGetFullName(account, gnc_get_account_separator());
title = g_strconcat(fullname, " - ", ADJ_BALN_STR, NULL);
free(fullname);
return title;
}
static void
gnc_adjb_set_window_name(AdjBWindow *adjBData)
{
char *title;
title = gnc_adjb_make_window_name(adjBData->account);
gtk_window_set_title(GTK_WINDOW(adjBData->dialog), title);
g_free(title);
}
/********************************************************************\
* adjBWindow *
* opens up the window to adjust the balance *
* *
* Args: account - the account to adjust *
* Return: adjBData - the instance of this AdjBWindow *
\********************************************************************/
AdjBWindow *
adjBWindow(Account *account)
{
GtkWidget *dialog, *frame, *vbox;
AdjBWindow *adjBData;
gchar *title;
FETCH_FROM_LIST(AdjBWindow, adjBList, account, account, adjBData);
title = gnc_adjb_make_window_name(account);
dialog = gnome_dialog_new(title,
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
g_free(title);
adjBData->account = account;
adjBData->dialog = dialog;
/* default to ok */
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
/* destroy, don't hide */
gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE);
vbox = GNOME_DIALOG(dialog)->vbox;
frame = gtk_frame_new(NULL);
gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
{
GtkTooltips *tooltips;
GtkWidget *hbox, *vbox;
GtkWidget *amount, *date;
GtkWidget *label, *entry;
const char *amount_str;
const char *currency;
char *string;
tooltips = gtk_tooltips_new();
hbox = gtk_hbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
gtk_container_add(GTK_CONTAINER(frame), hbox);
/* Label box */
vbox = gtk_vbox_new(TRUE, 3);
/* Date label */
string = g_strconcat(DATE_STR, ":", NULL);
label = gtk_label_new(string);
g_free(string);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
/* new balance label */
string = g_strconcat(NEW_BALN_STR, ":", NULL);
label = gtk_label_new(string);
g_free(string);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
/* Edit widget box */
vbox = gtk_vbox_new(TRUE, 3);
date = gnc_date_edit_new(time(NULL), FALSE, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), date, TRUE, TRUE, 0);
adjBData->date_entry = date;
entry = GNC_DATE_EDIT(date)->date_entry;
gtk_tooltips_set_tip(tooltips, entry, TOOLTIP_ADJUST_DATE, NULL);
amount = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(vbox), amount, TRUE, TRUE, 0);
adjBData->balance_entry = amount;
gtk_tooltips_set_tip(tooltips, amount, TOOLTIP_ADJUST_AMOUNT, NULL);
currency = xaccAccountGetCurrency(account);
amount_str = xaccPrintAmount(0.0, PRTSEP, currency);
gtk_entry_set_text(GTK_ENTRY(amount), amount_str);
gtk_entry_select_region(GTK_ENTRY(amount), 0, -1);
gtk_signal_connect(GTK_OBJECT(amount), "focus-out-event",
GTK_SIGNAL_FUNC(gnc_adjust_update_cb), account);
gnome_dialog_editable_enters(GNOME_DIALOG(dialog), GTK_EDITABLE(amount));
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
}
gnome_dialog_button_connect
(GNOME_DIALOG(dialog), 0,
GTK_SIGNAL_FUNC(gnc_ui_AdjBWindow_ok_cb), adjBData);
gnome_dialog_button_connect
(GNOME_DIALOG(dialog), 1,
GTK_SIGNAL_FUNC(gnc_ui_AdjBWindow_cancel_cb), adjBData);
gtk_signal_connect(GTK_OBJECT(dialog), "close",
GTK_SIGNAL_FUNC (gnc_ui_adjBWindow_close_cb),
adjBData);
gtk_widget_grab_focus(adjBData->balance_entry);
gtk_widget_show_all(dialog);
return adjBData;
}
/********************************************************************\
* Don't delete any structures, the close callback will do this *
\********************************************************************/
void
xaccDestroyAdjBWindow (Account *account)
{
AdjBWindow *adjBData;
FIND_IN_LIST(AdjBWindow, adjBList, account, account, adjBData);
if (adjBData == NULL)
return;
gnome_dialog_close(GNOME_DIALOG(adjBData->dialog));
}
/******************** END OF FILE ***********************************\
\********************************************************************/

View File

@ -30,7 +30,6 @@
#include "gnome-top-level.h"
#include "AccWindow.h"
#include "AdjBWindow.h"
#include "global-options.h"
#include "dialog-options.h"
#include "FileDialog.h"
@ -616,17 +615,6 @@ gnc_ui_mainWindow_transfer(GtkWidget *widget, gpointer data)
gnc_xfer_dialog(gnc_get_ui_data(), gnc_get_current_account());
}
static void
gnc_ui_mainWindow_adjust_balance(GtkWidget *widget, gpointer data)
{
Account *account = gnc_get_current_account();
if (account != NULL)
adjBWindow(account);
else
gnc_error_dialog(ACC_ADJUST_MSG);
}
static void
gnc_ui_mainWindow_scrub(GtkWidget *widget, gpointer data)
{
@ -1157,13 +1145,6 @@ gnc_main_create_menus(GnomeApp *app, GtkWidget *account_tree,
GNOME_APP_PIXMAP_NONE, NULL,
't', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
ADJ_BALN_MENU_E_STR_N, TOOLTIP_ADJUST_N,
gnc_ui_mainWindow_adjust_balance, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'b', GDK_CONTROL_MASK, NULL
},
GNOMEUIINFO_SEPARATOR,
{
GNOME_APP_UI_ITEM,

View File

@ -51,7 +51,6 @@
#include "enriched-messages.h"
#include "guile-util.h"
#include "AccWindow.h"
#include "AdjBWindow.h"
#include "Scrub.h"
#include "util.h"
#include "date.h"
@ -778,18 +777,6 @@ gnc_recn_xfer_cb(GtkWidget * w, gpointer data)
gnc_xfer_dialog(recnData->window, account);
}
static void
gnc_recn_adjust_cb(GtkWidget * w, gpointer data)
{
RecnWindow *recnData = data;
Account *account = recnData->account;
if (account == NULL)
return;
adjBWindow(account);
}
static void
gnc_recn_scrub_cb(GtkWidget *widget, gpointer data)
{
@ -1029,13 +1016,6 @@ gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar)
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
{
GNOME_APP_UI_ITEM,
ADJ_BALN_MENU_E_STR_N, TOOLTIP_ADJUST_N,
gnc_recn_adjust_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_SEPARATOR,
{
GNOME_APP_UI_ITEM,

View File

@ -42,7 +42,6 @@
#include "window-reconcile.h"
#include "AccWindow.h"
#include "window-help.h"
#include "AdjBWindow.h"
#include "dialog-transfer.h"
#include "dialog-utils.h"
#include "query-user.h"
@ -126,7 +125,6 @@ static void startRecnCB(GtkWidget *w, gpointer data);
static void xferCB(GtkWidget *w, gpointer data);
static void editCB(GtkWidget *w, gpointer data);
static void helpCB(GtkWidget *w, gpointer data);
static void startAdjBCB(GtkWidget * w, gpointer data);
static void newAccountCB(GtkWidget * w, gpointer data);
static void deleteCB(GtkWidget *w, gpointer data);
static void duplicateCB(GtkWidget *w, gpointer data);
@ -1221,13 +1219,6 @@ gnc_register_create_menu_bar(RegWindow *regData, GtkWidget *statusbar)
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
{
GNOME_APP_UI_ITEM,
ADJ_BALN_MENU_E_STR_N, TOOLTIP_ADJUST_REG_N,
startAdjBCB, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_SEPARATOR,
{
GNOME_APP_UI_ITEM,
@ -2026,28 +2017,6 @@ pasteTransCB(GtkWidget *w, gpointer data)
}
/********************************************************************\
* startAdjBCB -- open up the adjust balance window... called *
* from the menubar. *
* *
* Args: w - the widget that called us *
* data - the data struct for this register *
* Return: none *
\********************************************************************/
static void
startAdjBCB(GtkWidget * w, gpointer data)
{
RegWindow *regData = (RegWindow *) data;
xaccLedgerDisplay *ledger = regData->ledger;
Account *account = ledger->leader;
if (account == NULL)
return;
adjBWindow(account);
}
/********************************************************************\
* xferCB -- open up the transfer window *
* *