mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add new interface to create an account with a list of valid types
(so the caller can limit the account type(s) of a newly-created account) Add new interface to convert from UI-local account-type-string back to the account type enum. Use these interfaces in the date-close dialog. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6653 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -41,6 +41,8 @@ AccountWindow * gnc_ui_new_account_window_with_default(AccountGroup *group,
|
||||
AccountWindow * gnc_ui_edit_account_window (Account *account);
|
||||
|
||||
Account * gnc_ui_new_accounts_from_name_window (const char *name);
|
||||
Account * gnc_ui_new_accounts_from_name_window_with_types (const char *name,
|
||||
GList *valid_types);
|
||||
|
||||
void gnc_ui_set_default_new_account_currency (const char *currency);
|
||||
|
||||
|
||||
@@ -34,12 +34,13 @@ static Account *
|
||||
ask_make_acct (DialogDateClose *ddc, const char *name, gboolean new_acc)
|
||||
{
|
||||
char *message;
|
||||
GList *types = NULL;
|
||||
Account *acc;
|
||||
|
||||
if (new_acc) {
|
||||
gboolean result;
|
||||
message = g_strdup_printf (_("The %s account \"%s\" does not exist.\n"
|
||||
"Would you like to create it?"),
|
||||
xaccAccountGetTypeStr (ddc->acct_type), name);
|
||||
message = g_strdup_printf (_("The account \"%s\" does not exist.\n"
|
||||
"Would you like to create it?"), name);
|
||||
|
||||
result =
|
||||
gnc_verify_dialog_parented (ddc->dialog, message, TRUE);
|
||||
@@ -48,7 +49,10 @@ ask_make_acct (DialogDateClose *ddc, const char *name, gboolean new_acc)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return gnc_ui_new_accounts_from_name_window (name);
|
||||
types = g_list_append (types, (gpointer)(ddc->acct_type));
|
||||
acc = gnc_ui_new_accounts_from_name_window_with_types (name, types);
|
||||
g_list_free (types);
|
||||
return acc;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1974,6 +1974,24 @@ xaccAccountGetTypeStr(GNCAccountType type) {
|
||||
return _(account_type_name [type]);
|
||||
}
|
||||
|
||||
GNCAccountType
|
||||
xaccAccountGetTypeFromStr (const gchar *str)
|
||||
{
|
||||
gint type;
|
||||
|
||||
for (type = 0; type < NUM_ACCOUNT_TYPES; type++)
|
||||
{
|
||||
if (!safe_strcmp (str, _(account_type_name [type])))
|
||||
return type;
|
||||
}
|
||||
|
||||
PERR("asked to translate unknown account type string %s.\n",
|
||||
str ? str : "(null)");
|
||||
|
||||
return BAD_TYPE;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ typedef enum
|
||||
* to the local language.
|
||||
*/
|
||||
const char * xaccAccountGetTypeStr (GNCAccountType type);
|
||||
GNCAccountType xaccAccountGetTypeFromStr (const gchar *str);
|
||||
|
||||
/*
|
||||
* Conversion routines for the account types to/from strings
|
||||
|
||||
Reference in New Issue
Block a user