GnuCash  4.12-404-geb24099a91
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_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_window_with_types (GtkWindow *parent, const char *name, GList *valid_types)
 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 1932 of file dialog-account.c.

1933 {
1934  AccountWindow * aw;
1935  Account *parent_acct;
1936 
1937  if (account == NULL)
1938  return;
1939 
1940  aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
1941  find_by_account, account);
1942  if (aw)
1943  {
1944  gtk_window_present (GTK_WINDOW(aw->dialog));
1945  return;
1946  }
1947 
1948  aw = g_new0 (AccountWindow, 1);
1949 
1950  aw->book = gnc_account_get_book (account);
1951  aw->modal = FALSE;
1952  aw->dialog_type = EDIT_ACCOUNT;
1953  aw->account = *xaccAccountGetGUID (account);
1954  aw->subaccount_names = NULL;
1955  aw->type = xaccAccountGetType (account);
1956 
1957  gnc_suspend_gui_refresh ();
1958 
1959  gnc_account_window_create (parent, aw);
1960  gnc_account_to_ui (aw);
1961 
1962  gnc_resume_gui_refresh ();
1963 
1964  gtk_widget_show_all (aw->dialog);
1965  if (xaccAccountGetSplitList (account) != NULL)
1966  gtk_widget_hide (aw->opening_balance_page);
1967 
1968  parent_acct = gnc_account_get_parent (account);
1969  if (parent_acct == NULL)
1970  parent_acct = account; // must be at the root
1971 
1972  gtk_tree_view_collapse_all (aw->parent_tree);
1973  gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT(
1974  aw->parent_tree),
1975  parent_acct);
1976 
1977  gnc_account_window_set_name (aw);
1978 
1979  gnc_window_adjust_for_screen (GTK_WINDOW(aw->dialog));
1980 
1981  aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
1982  refresh_handler,
1983  close_handler, aw);
1984 
1985  gnc_gui_component_set_session (aw->component_id, gnc_get_current_session ());
1986  gnc_gui_component_watch_entity_type (aw->component_id,
1987  GNC_ID_ACCOUNT,
1988  QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
1989 
1990  gtk_window_present (GTK_WINDOW(aw->dialog));
1991 }
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
Definition: Account.cpp:2899
SplitList * xaccAccountGetSplitList(const Account *acc)
The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account...
Definition: Account.cpp:4007
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition: Account.cpp:3279
#define xaccAccountGetGUID(X)
Definition: Account.h:254
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 2000 of file dialog-account.c.

2002 {
2003  g_return_if_fail(book != NULL);
2004  if (parent_acct && book)
2005  g_return_if_fail(gnc_account_get_book (parent_acct) == book);
2006 
2007  gnc_ui_new_account_window_internal (parent, book, parent_acct, NULL, NULL,
2008  NULL, FALSE);
2009 }

◆ 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.

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

2014 {
2015  gnc_ui_new_account_window_internal (parent, book, NULL, NULL,
2016  valid_types, NULL, FALSE);
2017 }

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

1830 {
1831  return gnc_ui_new_accounts_from_name_with_defaults (parent, name, NULL,
1832  NULL, NULL);
1833 }
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_window_with_types()

Account* gnc_ui_new_accounts_from_name_window_with_types ( GtkWindow *  parent,
const char *  name,
GList *  valid_types 
)

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.
Returns
A pointer to the newly created account.

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

1839 {
1840  return gnc_ui_new_accounts_from_name_with_defaults (parent, name,
1841  valid_types, NULL, NULL);
1842 }
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 1845 of file dialog-account.c.

1850 {
1851  QofBook *book;
1852  AccountWindow *aw;
1853  Account *base_account = NULL;
1854  Account *created_account = NULL;
1855  gchar ** subaccount_names;
1856  gint response;
1857  gboolean done = FALSE;
1858 
1859  ENTER("name %s, valid %p, commodity %p, account %p",
1860  name, valid_types, default_commodity, parent_acct);
1861  book = gnc_get_current_book ();
1862  if (!name || *name == '\0')
1863  {
1864  subaccount_names = NULL;
1865  base_account = NULL;
1866  }
1867  else
1868  subaccount_names = gnc_split_account_name (book, name, &base_account);
1869 
1870  if (parent_acct != NULL)
1871  {
1872  base_account = parent_acct;
1873  }
1874  aw = gnc_ui_new_account_window_internal (parent, book, base_account,
1875  subaccount_names,
1876  valid_types,
1877  default_commodity,
1878  TRUE);
1879 
1880  while (!done)
1881  {
1882  response = gtk_dialog_run (GTK_DIALOG(aw->dialog));
1883 
1884  /* This can destroy the dialog */
1885  gnc_account_window_response_cb (GTK_DIALOG(aw->dialog), response, (gpointer)aw);
1886 
1887  switch (response)
1888  {
1889  case GTK_RESPONSE_OK:
1890  created_account = aw->created_account;
1891  done = (created_account != NULL);
1892  break;
1893 
1894  case GTK_RESPONSE_HELP:
1895  done = FALSE;
1896  break;
1897 
1898  default:
1899  done = TRUE;
1900  break;
1901  }
1902  }
1903 
1904  close_handler (aw);
1905  LEAVE("created %s (%p)", xaccAccountGetName (created_account), created_account);
1906  return created_account;
1907 }
#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:3301