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

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

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

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

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

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

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

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