GnuCash 2.3.0
Files | Functions
Creating and editing accounts in the GUI
GUI

Files

file  dialog-account.h
 

Dialog for create/edit an account.


Functions

void gnc_account_renumber_create_dialog (GtkWidget *window, Account *account)

Non-Modal

void gnc_ui_edit_account_window (Account *account)
void gnc_ui_new_account_window (QofBook *book, Account *parent)
void gnc_ui_new_account_with_types (QofBook *book, GList *valid_types)

Modal

Accountgnc_ui_new_accounts_from_name_window (const char *name)
Accountgnc_ui_new_accounts_from_name_window_with_types (const char *name, GList *valid_types)
Accountgnc_ui_new_accounts_from_name_with_defaults (const char *name, GList *valid_types, const gnc_commodity *default_commodity, Account *parent)
void gnc_ui_register_account_destroy_callback (void(*cb)(Account *))

Function Documentation

void gnc_ui_edit_account_window ( Account account)

Disply a window for editing the attributes of an existing account.

Parameters:
accountThis parameter specifies the account whose data will be edited.

Definition at line 1792 of file dialog-account.c.

{
    AccountWindow * aw;
    Account *parent;

    if (account == NULL)
        return;

    aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
                                       find_by_account, account);
    if (aw)
    {
        gtk_window_present(GTK_WINDOW(aw->dialog));
        return;
    }

    aw = g_new0 (AccountWindow, 1);

    aw->book = gnc_account_get_book(account);
    aw->modal = FALSE;
    aw->dialog_type = EDIT_ACCOUNT;
    aw->account = *xaccAccountGetGUID (account);
    aw->subaccount_names = NULL;
    aw->type = xaccAccountGetType (account);

    gnc_suspend_gui_refresh ();

    gnc_account_window_create (aw);
    gnc_account_to_ui (aw);

    gnc_resume_gui_refresh ();

    gtk_widget_show_all (aw->dialog);
    gtk_widget_hide (aw->opening_balance_page);

    parent = gnc_account_get_parent (account);
    if (parent == NULL)
        parent = account;               /* must be at the root */

    gtk_tree_view_collapse_all (aw->parent_tree);
    gnc_tree_view_account_set_selected_account (
        GNC_TREE_VIEW_ACCOUNT(aw->parent_tree), parent);

    gnc_account_window_set_name (aw);

    gnc_window_adjust_for_screen(GTK_WINDOW(aw->dialog));

    aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
                       refresh_handler,
                       close_handler, aw);

    gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
    gnc_gui_component_watch_entity_type (aw->component_id,
                                         GNC_ID_ACCOUNT,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

    gtk_window_present(GTK_WINDOW(aw->dialog));
}
void gnc_ui_new_account_window ( QofBook book,
Account parent 
)

Disply a window for creating a new account. This function will also initially set the parent account of the new account to what the caller specified. The user is free, however, to choose any parent account they wish.

Parameters:
bookThe book in which the new account should be created. This is a required argument.
parentThe initially selected parent account. This argument is optional, but if supplied must be an account contained in the specified book.

Definition at line 1859 of file dialog-account.c.

{
    g_return_if_fail(book != NULL);
    if (parent && book)
        g_return_if_fail(gnc_account_get_book(parent) == book);

    gnc_ui_new_account_window_internal (book, parent, NULL, NULL, NULL, FALSE);
}
void gnc_ui_new_account_with_types ( QofBook book,
GList *  valid_types 
)

Disply a window for creating a new account. This function will restrict the available account type values to the list specified by the caller.

Parameters:
bookThe book in which the new account should be created. This is a required argument.
valid_typesA GList of GNCAccountType gints [as pointers] which are allowed to be created. The calling function is responsible for freeing this list.

Definition at line 1869 of file dialog-account.c.

{
    gnc_ui_new_account_window_internal( book, NULL, NULL, valid_types, NULL, FALSE );
}
Account* gnc_ui_new_accounts_from_name_window ( const char *  name)

Disply a modal window for creating a new account

Parameters:
nameThe account name/path to be created. This parameter is not used for determining the initially selected parent account.

Definition at line 1695 of file dialog-account.c.

{
    return  gnc_ui_new_accounts_from_name_with_defaults (name, NULL, NULL, NULL);
}
Account* gnc_ui_new_accounts_from_name_window_with_types ( const char *  name,
GList *  valid_types 
)

Disply a modal window for creating a new account. This function will restrict the available account type values to the list specified by the caller.

Parameters:
nameThe account name/path to be created. This parameter is not used for determining the initially selected parent account.
valid_typesA GList of GNCAccountType gints [as pointers] which are allowed to be created. The calling function is responsible for freeing this list.
Returns:
A pointer to the newly created account.

Definition at line 1701 of file dialog-account.c.

{
    return gnc_ui_new_accounts_from_name_with_defaults(name, valid_types, NULL, NULL);
}
Account* gnc_ui_new_accounts_from_name_with_defaults ( const char *  name,
GList *  valid_types,
const gnc_commodity default_commodity,
Account parent 
)

Display a modal window for creating a new account. This function will restrict the available account type values to the list specified by the caller.

Parameters:
nameThe account name/path to be created. This parameter is not used for determining the initially selected parent account.
valid_typesA GList of GNCAccountType gints [as pointers] which are allowed to be created. The calling function is responsible for freeing this list.
default_commodityThe commodity to initially select when the dialog is presented.
parentThe initially selected parent account.
Returns:
A pointer to the newly created account.

Definition at line 1708 of file dialog-account.c.

{
    QofBook *book;
    AccountWindow *aw;
    Account *base_account = NULL;
    Account *created_account = NULL;
    gchar ** subaccount_names;
    gint response;
    gboolean done = FALSE;

    ENTER("name %s, valid %p, commodity %p, account %p",
          name, valid_types, default_commodity, parent);
    book = gnc_get_current_book();
    if (!name || *name == '\0')
    {
        subaccount_names = NULL;
        base_account = NULL;
    }
    else
        subaccount_names = gnc_split_account_name (book, name, &base_account);

    if (parent != NULL)
    {
        base_account = parent;
    }
    aw = gnc_ui_new_account_window_internal (book, base_account, subaccount_names,
            valid_types, default_commodity,
            TRUE);

    while (!done)
    {
        response = gtk_dialog_run (GTK_DIALOG(aw->dialog));

        /* This can destroy the dialog */
        gnc_account_window_response_cb (GTK_DIALOG(aw->dialog), response, (gpointer)aw);

        switch (response)
        {
        case GTK_RESPONSE_OK:
            created_account = aw->created_account;
            done = (created_account != NULL);
            break;

        case GTK_RESPONSE_HELP:
            done = FALSE;
            break;

        default:
            done = TRUE;
            break;
        }
    }

    close_handler(aw);
    LEAVE("created %s (%p)", xaccAccountGetName(created_account), created_account);
    return created_account;
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines