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 2098 of file dialog-account.c.

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

2176 {
2177  g_return_if_fail(book != NULL);
2178  if (parent_acct && book)
2179  g_return_if_fail(gnc_account_get_book (parent_acct) == book);
2180 
2181  gnc_ui_new_account_window_internal (parent, book, parent_acct, NULL, NULL,
2182  NULL, FALSE);
2183 }

◆ 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 2160 of file dialog-account.c.

2162 {
2163  gnc_ui_new_account_window_internal (parent, book, NULL, NULL,
2164  valid_types, default_commodity, FALSE);
2165 }

◆ 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 2004 of file dialog-account.c.

2005 {
2006  return gnc_ui_new_accounts_from_name_with_defaults (parent, name, NULL,
2007  NULL, NULL);
2008 }
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 2011 of file dialog-account.c.

2016 {
2017  QofBook *book;
2018  AccountWindow *aw;
2019  Account *base_account = NULL;
2020  Account *created_account = NULL;
2021  gchar ** subaccount_names;
2022  gint response;
2023  gboolean done = FALSE;
2024 
2025  ENTER("name %s, valid %p, commodity %p, account %p",
2026  name, valid_types, default_commodity, parent_acct);
2027  book = gnc_get_current_book ();
2028  if (!name || *name == '\0')
2029  {
2030  subaccount_names = NULL;
2031  base_account = NULL;
2032  }
2033  else
2034  subaccount_names = gnc_split_account_name (book, name, &base_account);
2035 
2036  if (parent_acct != NULL)
2037  {
2038  base_account = parent_acct;
2039  }
2040  aw = gnc_ui_new_account_window_internal (parent, book, base_account,
2041  subaccount_names,
2042  valid_types,
2043  default_commodity,
2044  TRUE);
2045 
2046  while (!done)
2047  {
2048  response = gtk_dialog_run (GTK_DIALOG(aw->dialog));
2049 
2050  /* This can destroy the dialog */
2051  gnc_account_window_response_cb (GTK_DIALOG(aw->dialog), response, (gpointer)aw);
2052 
2053  switch (response)
2054  {
2055  case GTK_RESPONSE_OK:
2056  created_account = aw->created_account;
2057  done = (created_account != NULL);
2058  break;
2059 
2060  case GTK_RESPONSE_HELP:
2061  done = FALSE;
2062  break;
2063 
2064  default:
2065  done = TRUE;
2066  break;
2067  }
2068  }
2069 
2070  close_handler (aw);
2071  LEAVE("created %s (%p)", xaccAccountGetName (created_account), created_account);
2072  return created_account;
2073 }
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:3239