GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Functions
Creating and editing accounts in the GUI

Files

 

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 *))
 

Detailed Description

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.

1793 {
1794  AccountWindow * aw;
1795  Account *parent;
1796 
1797  if (account == NULL)
1798  return;
1799 
1800  aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
1801  find_by_account, account);
1802  if (aw)
1803  {
1804  gtk_window_present(GTK_WINDOW(aw->dialog));
1805  return;
1806  }
1807 
1808  aw = g_new0 (AccountWindow, 1);
1809 
1810  aw->book = gnc_account_get_book(account);
1811  aw->modal = FALSE;
1812  aw->dialog_type = EDIT_ACCOUNT;
1813  aw->account = *xaccAccountGetGUID (account);
1814  aw->subaccount_names = NULL;
1815  aw->type = xaccAccountGetType (account);
1816 
1817  gnc_suspend_gui_refresh ();
1818 
1819  gnc_account_window_create (aw);
1820  gnc_account_to_ui (aw);
1821 
1822  gnc_resume_gui_refresh ();
1823 
1824  gtk_widget_show_all (aw->dialog);
1825  gtk_widget_hide (aw->opening_balance_page);
1826 
1827  parent = gnc_account_get_parent (account);
1828  if (parent == NULL)
1829  parent = account; /* must be at the root */
1830 
1831  gtk_tree_view_collapse_all (aw->parent_tree);
1833  GNC_TREE_VIEW_ACCOUNT(aw->parent_tree), parent);
1834 
1835  gnc_account_window_set_name (aw);
1836 
1837  gnc_window_adjust_for_screen(GTK_WINDOW(aw->dialog));
1838 
1839  aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
1840  refresh_handler,
1841  close_handler, aw);
1842 
1843  gnc_gui_component_set_session (aw->component_id, gnc_get_current_session());
1844  gnc_gui_component_watch_entity_type (aw->component_id,
1845  GNC_ID_ACCOUNT,
1846  QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
1847 
1848  gtk_window_present(GTK_WINDOW(aw->dialog));
1849 }
Account * gnc_account_get_parent(const Account *acc)
Definition: Account.c:2623
GNCAccountType xaccAccountGetType(const Account *acc)
Definition: Account.c:3009
#define xaccAccountGetGUID(X)
Definition: Account.h:239
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
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.

1860 {
1861  g_return_if_fail(book != NULL);
1862  if (parent && book)
1863  g_return_if_fail(gnc_account_get_book(parent) == book);
1864 
1865  gnc_ui_new_account_window_internal (book, parent, NULL, NULL, NULL, FALSE);
1866 }
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.

1871 {
1872  gnc_ui_new_account_window_internal( book, NULL, NULL, valid_types, NULL, FALSE );
1873 }
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.

1696 {
1697  return gnc_ui_new_accounts_from_name_with_defaults (name, NULL, NULL, NULL);
1698 }
Account * gnc_ui_new_accounts_from_name_with_defaults(const char *name, GList *valid_types, const gnc_commodity *default_commodity, Account *parent)
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.

1703 {
1704  return gnc_ui_new_accounts_from_name_with_defaults(name, valid_types, NULL, NULL);
1705 }
Account * gnc_ui_new_accounts_from_name_with_defaults(const char *name, GList *valid_types, const gnc_commodity *default_commodity, Account *parent)
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.

1712 {
1713  QofBook *book;
1714  AccountWindow *aw;
1715  Account *base_account = NULL;
1716  Account *created_account = NULL;
1717  gchar ** subaccount_names;
1718  gint response;
1719  gboolean done = FALSE;
1720 
1721  ENTER("name %s, valid %p, commodity %p, account %p",
1722  name, valid_types, default_commodity, parent);
1723  book = gnc_get_current_book();
1724  if (!name || *name == '\0')
1725  {
1726  subaccount_names = NULL;
1727  base_account = NULL;
1728  }
1729  else
1730  subaccount_names = gnc_split_account_name (book, name, &base_account);
1731 
1732  if (parent != NULL)
1733  {
1734  base_account = parent;
1735  }
1736  aw = gnc_ui_new_account_window_internal (book, base_account, subaccount_names,
1737  valid_types, default_commodity,
1738  TRUE);
1739 
1740  while (!done)
1741  {
1742  response = gtk_dialog_run (GTK_DIALOG(aw->dialog));
1743 
1744  /* This can destroy the dialog */
1745  gnc_account_window_response_cb (GTK_DIALOG(aw->dialog), response, (gpointer)aw);
1746 
1747  switch (response)
1748  {
1749  case GTK_RESPONSE_OK:
1750  created_account = aw->created_account;
1751  done = (created_account != NULL);
1752  break;
1753 
1754  case GTK_RESPONSE_HELP:
1755  done = FALSE;
1756  break;
1757 
1758  default:
1759  done = TRUE;
1760  break;
1761  }
1762  }
1763 
1764  close_handler(aw);
1765  LEAVE("created %s (%p)", xaccAccountGetName(created_account), created_account);
1766  return created_account;
1767 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
const char * xaccAccountGetName(const Account *acc)
Definition: Account.c:3031