GnuCash  5.6-150-g038405b370+
Files | Functions
Creating and editing accounts in the GUI

Files

 

Functions

void gnc_account_renumber_create_dialog (GtkWidget *window, Account *account)
 
void gnc_account_cascade_properties_dialog (GtkWidget *window, Account *account)
 

Non-Modal

void gnc_ui_edit_account_window (GtkWindow *parent, Account *account)
 Display a window for editing the attributes of an existing account. More...
 
void gnc_ui_new_account_with_types_and_commodity (GtkWindow *parent, QofBook *book, GList *valid_types, gnc_commodity *)
 Display a window for creating a new account. More...
 
void gnc_ui_new_account_window (GtkWindow *parent, QofBook *book, Account *parent_acct)
 Display a window for creating a new account. More...
 
void gnc_ui_new_account_with_types (GtkWindow *parent, QofBook *book, GList *valid_types)
 Display a window for creating a new account. More...
 

Modal

Accountgnc_ui_new_accounts_from_name_window (GtkWindow *parent, const char *name)
 Display a modal window for creating a new account. More...
 
Accountgnc_ui_new_accounts_from_name_with_defaults (GtkWindow *parent, const char *name, GList *valid_types, const gnc_commodity *default_commodity, Account *parent_acct)
 Display a modal window for creating a new account. More...
 
void gnc_ui_register_account_destroy_callback (void(*cb)(Account *))
 

Detailed Description

Function Documentation

◆ gnc_ui_edit_account_window()

void gnc_ui_edit_account_window ( GtkWindow *  parent,
Account account 
)

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

Parameters
parentThe widget on which to parent the dialog.
accountThis parameter specifies the account whose data will be edited.

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

2103 {
2104  AccountWindow * aw;
2105  Account *parent_acct;
2106 
2107  if (account == NULL)
2108  return;
2109 
2110  aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
2111  find_by_account, account);
2112  if (aw)
2113  {
2114  gtk_window_present (GTK_WINDOW(aw->dialog));
2115  return;
2116  }
2117 
2118  aw = g_new0 (AccountWindow, 1);
2119 
2120  aw->book = gnc_account_get_book (account);
2121  aw->modal = FALSE;
2122  aw->dialog_type = EDIT_ACCOUNT;
2123  aw->account = *xaccAccountGetGUID (account);
2124  aw->subaccount_names = NULL;
2125  aw->type = xaccAccountGetType (account);
2126 
2127  gnc_suspend_gui_refresh ();
2128 
2129  gnc_account_window_create (parent, aw);
2130  gnc_account_to_ui (aw);
2131 
2132  gnc_resume_gui_refresh ();
2133 
2134  gtk_widget_show_all (aw->dialog);
2135  if (xaccAccountGetSplitsSize (account) != 0)
2136  gtk_widget_hide (aw->opening_balance_page);
2137 
2138  parent_acct = gnc_account_get_parent (account);
2139  if (parent_acct == NULL)
2140  parent_acct = account; // must be at the root
2141 
2142  gtk_tree_view_collapse_all (aw->parent_tree);
2143  gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT(
2144  aw->parent_tree),
2145  parent_acct);
2146 
2147  gnc_account_window_set_name (aw);
2148 
2149  gnc_window_adjust_for_screen (GTK_WINDOW(aw->dialog));
2150 
2151  aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
2152  refresh_handler,
2153  close_handler, aw);
2154 
2155  gnc_gui_component_set_session (aw->component_id, gnc_get_current_session ());
2156  gnc_gui_component_watch_entity_type (aw->component_id,
2157  GNC_ID_ACCOUNT,
2158  QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
2159 
2160  gtk_window_present (GTK_WINDOW(aw->dialog));
2161 }
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
Definition: Account.cpp:2902
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition: Account.cpp:3234
STRUCTS.
#define xaccAccountGetGUID(X)
Definition: Account.h:252
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.

◆ gnc_ui_new_account_window()

void gnc_ui_new_account_window ( GtkWindow *  parent,
QofBook *  book,
Account parent_acct 
)

Display 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
parentThe widget on which to parent the dialog.
bookThe book in which the new account should be created. This is a required argument.
parent_acctThe initially selected parent account. This argument is optional, but if supplied must be an account contained in the specified book.

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

2180 {
2181  g_return_if_fail(book != NULL);
2182  if (parent_acct && book)
2183  g_return_if_fail(gnc_account_get_book (parent_acct) == book);
2184 
2185  gnc_ui_new_account_window_internal (parent, book, parent_acct, NULL, NULL,
2186  NULL, FALSE);
2187 }

◆ gnc_ui_new_account_with_types()

void gnc_ui_new_account_with_types ( GtkWindow *  parent,
QofBook *  book,
GList *  valid_types 
)

Display a window for creating a new account.

This function will restrict the available account type values to the list specified by the caller.

Parameters
parentThe widget on which to parent the dialog.
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.

◆ gnc_ui_new_account_with_types_and_commodity()

void gnc_ui_new_account_with_types_and_commodity ( GtkWindow *  parent,
QofBook *  book,
GList *  valid_types,
gnc_commodity *   
)

Display a window for creating a new account.

This function will restrict the available account type values to the list specified by the caller.

Parameters
parentThe widget on which to parent the dialog.
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.
default_commodityA gnc_commodity* to specify the default commodity to create. May be NULL.

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

2166 {
2167  gnc_ui_new_account_window_internal (parent, book, NULL, NULL,
2168  valid_types, default_commodity, FALSE);
2169 }

◆ gnc_ui_new_accounts_from_name_window()

Account* gnc_ui_new_accounts_from_name_window ( GtkWindow *  parent,
const char *  name 
)

Display a modal window for creating a new account.

Parameters
parentThe widget on which to parent the dialog.
nameThe account name/path to be created. This parameter is not used for determining the initially selected parent account.

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

2009 {
2010  return gnc_ui_new_accounts_from_name_with_defaults (parent, name, NULL,
2011  NULL, NULL);
2012 }
Account * gnc_ui_new_accounts_from_name_with_defaults(GtkWindow *parent, const char *name, GList *valid_types, const gnc_commodity *default_commodity, Account *parent_acct)
Display a modal window for creating a new account.

◆ gnc_ui_new_accounts_from_name_with_defaults()

Account* gnc_ui_new_accounts_from_name_with_defaults ( GtkWindow *  parent,
const char *  name,
GList *  valid_types,
const gnc_commodity *  default_commodity,
Account parent_acct 
)

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
parentThe widget on which to parent the dialog.
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.
parent_acctThe initially selected parent account.
Returns
A pointer to the newly created account.

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

2020 {
2021  QofBook *book;
2022  AccountWindow *aw;
2023  Account *base_account = NULL;
2024  Account *created_account = NULL;
2025  gchar ** subaccount_names;
2026  gint response;
2027  gboolean done = FALSE;
2028 
2029  ENTER("name %s, valid %p, commodity %p, account %p",
2030  name, valid_types, default_commodity, parent_acct);
2031  book = gnc_get_current_book ();
2032  if (!name || *name == '\0')
2033  {
2034  subaccount_names = NULL;
2035  base_account = NULL;
2036  }
2037  else
2038  subaccount_names = gnc_split_account_name (book, name, &base_account);
2039 
2040  if (parent_acct != NULL)
2041  {
2042  base_account = parent_acct;
2043  }
2044  aw = gnc_ui_new_account_window_internal (parent, book, base_account,
2045  subaccount_names,
2046  valid_types,
2047  default_commodity,
2048  TRUE);
2049 
2050  while (!done)
2051  {
2052  response = gtk_dialog_run (GTK_DIALOG(aw->dialog));
2053 
2054  /* This can destroy the dialog */
2055  gnc_account_window_response_cb (GTK_DIALOG(aw->dialog), response, (gpointer)aw);
2056 
2057  switch (response)
2058  {
2059  case GTK_RESPONSE_OK:
2060  created_account = aw->created_account;
2061  done = (created_account != NULL);
2062  break;
2063 
2064  case GTK_RESPONSE_HELP:
2065  done = FALSE;
2066  break;
2067 
2068  default:
2069  done = TRUE;
2070  break;
2071  }
2072  }
2073 
2074  close_handler (aw);
2075  LEAVE("created %s (%p)", xaccAccountGetName (created_account), created_account);
2076  return created_account;
2077 }
STRUCTS.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition: Account.cpp:3256