More work on auto-account feature in register.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3217 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-12-01 06:28:16 +00:00
parent 66827f9234
commit 9415ee13b5
4 changed files with 67 additions and 27 deletions

View File

@ -38,7 +38,8 @@ typedef struct _AccountWindow AccountWindow;
AccountWindow * gnc_ui_new_account_window (AccountGroup *group);
AccountWindow * gnc_ui_edit_account_window (Account *account);
AccountWindow * gnc_ui_new_accounts_from_name_window (const char *name);
Account * gnc_ui_new_accounts_from_name_window (const char *name);
/* The xaccDestroyEditAccWindow() subroutine can be called from
* anywhere to shut down the Register window. Used primarily when

View File

@ -1241,9 +1241,14 @@ LedgerTraverse (Table *table,
break;
}
gnc_ui_new_accounts_from_name_window (name);
account = gnc_ui_new_accounts_from_name_window (name);
if (!account)
break;
return TRUE;
name = xaccAccountGetFullName (account, account_separator);
xaccSetComboCellValue (cell, name);
xaccBasicCellSetChanged (&cell->cell, TRUE);
g_free (name);
} while (FALSE);

View File

@ -62,6 +62,7 @@ struct _AccountWindow
Account *account;
Account *top_level_account;
Account *created_account;
GList *subaccount_names;
@ -290,6 +291,9 @@ gnc_finish_ok (AccountWindow *aw)
return;
}
/* save for posterity */
aw->created_account = aw->account;
/* so it doesn't get freed on close */
aw->account = NULL;
@ -1026,14 +1030,14 @@ gnc_account_window_help_cb(GtkWidget *widget, gpointer data)
static int
gnc_account_window_close_cb (GnomeDialog *dialog, gpointer data)
gnc_account_window_destroy_cb (GtkObject *object, gpointer data)
{
AccountWindow *aw = data;
switch (aw->dialog_type)
{
case NEW_ACCOUNT:
new_account_windows = g_list_remove (new_account_windows, dialog);
new_account_windows = g_list_remove (new_account_windows, object);
if (aw->account != NULL)
{
@ -1068,7 +1072,7 @@ gnc_account_window_close_cb (GnomeDialog *dialog, gpointer data)
g_free (aw);
gdk_window_get_geometry (GTK_WIDGET(dialog)->window, NULL, NULL,
gdk_window_get_geometry (GTK_WIDGET(object)->window, NULL, NULL,
&last_width, &last_height, NULL);
gnc_save_window_size ("account_win", last_width, last_height);
@ -1246,15 +1250,17 @@ gnc_account_window_create(AccountWindow *aw)
GtkObject *awo;
GtkWidget *box;
aw->dialog = create_Account_Dialog();
awo = GTK_OBJECT(aw->dialog);
awd = GNOME_DIALOG(awo);
aw->dialog = create_Account_Dialog ();
awo = GTK_OBJECT (aw->dialog);
awd = GNOME_DIALOG (awo);
gtk_object_set_data (awo, "dialog_info", aw);
/* default to ok */
gnome_dialog_set_default(awd, 0);
gtk_signal_connect(awo, "close",
GTK_SIGNAL_FUNC(gnc_account_window_close_cb), aw);
gtk_signal_connect(awo, "destroy",
GTK_SIGNAL_FUNC(gnc_account_window_destroy_cb), aw);
gnome_dialog_button_connect
(awd, 0, GTK_SIGNAL_FUNC(gnc_account_window_ok_cb), aw);
@ -1514,18 +1520,37 @@ gnc_split_account_name (const char *in_name, Account **base_account)
}
AccountWindow *
static int
from_name_close_cb (GnomeDialog *dialog, gpointer data)
{
AccountWindow *aw;
Account **created_account = data;
aw = gtk_object_get_data (GTK_OBJECT (dialog), "dialog_info");
*created_account = aw->created_account;
gtk_main_quit ();
return FALSE;
}
Account *
gnc_ui_new_accounts_from_name_window (const char *name)
{
AccountWindow *aw;
Account *base_account;
Account *created_account;
GList * subaccount_names;
GList * node;
if (!name || *name == '\0')
return gnc_ui_new_account_window (NULL);
subaccount_names = gnc_split_account_name (name, &base_account);
{
subaccount_names = NULL;
base_account = NULL;
}
else
subaccount_names = gnc_split_account_name (name, &base_account);
aw = gnc_ui_new_account_window_internal (base_account, subaccount_names);
@ -1533,7 +1558,12 @@ gnc_ui_new_accounts_from_name_window (const char *name)
g_free (node->data);
g_list_free (subaccount_names);
return aw;
gtk_signal_connect(GTK_OBJECT (aw->dialog), "close",
GTK_SIGNAL_FUNC (from_name_close_cb), &created_account);
gtk_main ();
return created_account;
}

View File

@ -49,35 +49,39 @@
#include "gnc-common.h"
typedef struct _ComboCell {
BasicCell cell;
typedef struct _ComboCell
{
BasicCell cell;
} ComboCell;
ComboCell * xaccMallocComboCell (void);
void xaccInitComboCell (ComboCell *);
void xaccDestroyComboCell (ComboCell *);
void xaccInitComboCell (ComboCell *cell);
void xaccDestroyComboCell (ComboCell *cell);
void xaccSetComboCellValue (ComboCell *, const char *);
void xaccSetComboCellValue (ComboCell *cell, const char *value);
void xaccClearComboCellMenu (ComboCell *);
void xaccAddComboCellMenuItem (ComboCell *, char * menustr);
void xaccClearComboCellMenu (ComboCell *cell);
void xaccAddComboCellMenuItem (ComboCell *cell, char * menustr);
/* Determines whether the cell will accept strings not in the
* menu. Defaults to strict, i.e., only menu items are accepted. */
void xaccComboCellSetStrict (ComboCell *, gboolean);
void xaccComboCellSetStrict (ComboCell *cell, gboolean strict);
/* Sets a character used for special completion processing. */
void xaccComboCellSetCompleteChar (ComboCell *, char);
void xaccComboCellSetCompleteChar (ComboCell *cell,
char complete_char);
/* Sets a string which, if the cell has that value, will be returned
* on an enter, thus preventing the cell from being edited. This is
* used for transactions with multiple splits. */
void xaccComboCellSetIgnoreString (ComboCell *, const char *);
void xaccComboCellSetIgnoreString (ComboCell *cell,
const char *ignore_string);
/* Sets a string which, if the cell has the ignore value, will be
* returned as the help string. */
void xaccComboCellSetIgnoreHelp (ComboCell *, const char *);
void xaccComboCellSetIgnoreHelp (ComboCell *cell,
const char *ignore_help);
/* Determines whether combocells are automatically raised upon typing.
* Defaults to false. This is a 'class' method. */