mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move price quote information from the Account data structure to the
Commodity data structure. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8292 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bcbf5c847a
commit
5b7353d67c
41
ChangeLog
41
ChangeLog
@ -1,5 +1,46 @@
|
||||
2003-05-10 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/backend/file/gnc-commodity-xml-v2.c:
|
||||
* src/engine/gnc-commodity.c:
|
||||
* src/engine/gnc-commodity.h:
|
||||
* src/gnome/glade/account.glade:
|
||||
* src/gnome-utils/commodity.glade:
|
||||
* src/gnome-utils/dialog-account.c:
|
||||
* src/gnome-utils/dialog-commodity.c:
|
||||
* src/gnome-utils/dialog-commodity.h:
|
||||
* src/gnome-utils/dialog-utils.c:
|
||||
* src/gnome-utils/dialog-utils.h: Migrate fields and functions
|
||||
related to price quotes from the account to the commodity.
|
||||
|
||||
* src/backend/file/io-gncxml-v2.c:
|
||||
* src/engine/Scrub.c:
|
||||
* src/engine/Scrub.h: Migrate price quote information when reading
|
||||
in the data file.
|
||||
|
||||
* src/app-utils/gnc-helpers.c:
|
||||
* src/app-utils/gnc-helpers.h:
|
||||
* src/app-utils/gw-app-utils-spec.scm:
|
||||
* src/engine/gw-engine-spec.scm:
|
||||
* src/scm/price-quotes.scm: The code to get quotes from F::Q now
|
||||
needs to get the information from the commodity data structures,
|
||||
not the Account data structures.
|
||||
|
||||
* src/backend/file/gnc-account-xml-v2.c: Continue to write out
|
||||
price quote information with the Account data. This allows users
|
||||
to fall pack to production code without loss of information. This
|
||||
code will drop out in the next release of gnucash (1.10 or 2.0).
|
||||
|
||||
* src/engine/Account.c:
|
||||
* src/engine/Account.h: Deprecated a couple of functions.
|
||||
Continue existing hack of automatically marking cross currency
|
||||
accounts for automatic quote retrieval.
|
||||
|
||||
* src/backend/file/io-gncbin-r.c: Update for the new names of
|
||||
deprecated functions.
|
||||
|
||||
* src/import-export/import-commodity-matcher.c: Update for changed
|
||||
calling conventions.
|
||||
|
||||
* configure.in: Restore some lost changes.
|
||||
|
||||
2003-05-09 Christian Stimming <stimming@tuhh.de>
|
||||
|
@ -26,11 +26,13 @@
|
||||
#include <libguile.h>
|
||||
#include "guile-mappings.h"
|
||||
#include <string.h>
|
||||
#include <g-wrap-wct.h>
|
||||
|
||||
#include "gnc-engine-util.h"
|
||||
#include "engine-helpers.h"
|
||||
#include "gnc-helpers.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "global-options.h"
|
||||
|
||||
|
||||
static short module = MOD_SX;
|
||||
@ -118,6 +120,45 @@ gnc_printinfo_p(SCM info_scm)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* This is a scaled down version of the routine that would be needed
|
||||
* to fully convert a gnc-commodity to a scheme data structure. In an
|
||||
* attempt to optimize the speed of price quote retrieval, this
|
||||
* routine only converts the fields that price-quotes.scm uses. Since
|
||||
* it converts these fields all at once, it should prevent multiple
|
||||
* transitions back and forth from Scheme to C (via g-wrap) to extract
|
||||
* the data from a pointers to a gnc-commodity (the older method).
|
||||
* This is *not* a reversible conversion as it drops data.
|
||||
*
|
||||
* When this routine was written, gnucash retrieved all quotes into
|
||||
* the user's default currency. (Did earlier version do any
|
||||
* different?) This routine inserts that default currency into the
|
||||
* returned structure as another optimization.
|
||||
*/
|
||||
SCM
|
||||
gnc_quoteinfo2scm(gnc_commodity *comm)
|
||||
{
|
||||
const char *source, *tz;
|
||||
SCM info_scm = SCM_EOL, comm_scm, def_comm_scm;
|
||||
|
||||
if (!comm)
|
||||
return SCM_EOL;
|
||||
|
||||
source = gnc_price_source_internal2fq (gnc_commodity_get_quote_source (comm));
|
||||
tz = gnc_commodity_get_quote_tz (comm);
|
||||
comm_scm = gw_wcp_assimilate_ptr (comm, scm_c_eval_string("<gnc:commodity*>"));
|
||||
def_comm_scm = gw_wcp_assimilate_ptr (gnc_default_currency (),
|
||||
scm_c_eval_string("<gnc:commodity*>"));
|
||||
|
||||
if (tz)
|
||||
info_scm = scm_cons (scm_makfrom0str (tz), info_scm);
|
||||
else
|
||||
info_scm = scm_cons (SCM_BOOL_F, info_scm);
|
||||
info_scm = scm_cons (def_comm_scm, info_scm);
|
||||
info_scm = scm_cons (comm_scm, info_scm);
|
||||
info_scm = scm_cons (scm_makfrom0str (source), info_scm);
|
||||
return info_scm;
|
||||
}
|
||||
|
||||
const char *
|
||||
gnc_get_account_separator_string (void)
|
||||
{
|
||||
|
@ -32,6 +32,17 @@ SCM gnc_printinfo2scm(GNCPrintAmountInfo info);
|
||||
GNCPrintAmountInfo gnc_scm2printinfo(SCM info_scm);
|
||||
int gnc_printinfo_p(SCM info_scm);
|
||||
|
||||
/** Given a pointer to a gnc-commodity data structure, build a Scheme
|
||||
* list containing the data needed by the code in price-quotes.scm.
|
||||
* This prevents flipping back and forth from Scheme to C while
|
||||
* extracting values from a pointer.
|
||||
*
|
||||
* @param com A pointer to the commodity to convert.
|
||||
*
|
||||
* @return A pointer to a Scheme list, or SCM_EOL on error.
|
||||
*/
|
||||
SCM gnc_quoteinfo2scm(gnc_commodity *com);
|
||||
|
||||
const char * gnc_get_account_separator_string (void);
|
||||
|
||||
SCM gnc_parse_amount_helper (const char * string, gboolean monetary);
|
||||
|
@ -42,6 +42,11 @@
|
||||
'(c-var " = gnc_scm2printinfo(" scm-var ");\n")
|
||||
'(scm-var " = gnc_printinfo2scm(" c-var ");\n"))
|
||||
|
||||
(gw:wrap-simple-type ws '<gnc:quote-info-scm> "gnc_commodity *"
|
||||
'("FALSE")
|
||||
'(c-var " = NULL;\n")
|
||||
'(scm-var " = gnc_quoteinfo2scm(" c-var ");\n"))
|
||||
|
||||
(gw:wrap-as-wct ws
|
||||
'<gnc:OptionChangeCallback>
|
||||
"GNCOptionChangeCallback" "const GNCOptionChangeCallback")
|
||||
@ -462,6 +467,16 @@ determines formatting details.")
|
||||
'(((gw:glist-of (<gw:mchars> callee-owned) callee-owned) choices))
|
||||
"Takes a list of installed Finance::Quote souces and records it internally.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:commodity-table-get-quotable-commodities-info
|
||||
'(gw:glist-of <gnc:quote-info-scm> caller-owned)
|
||||
"gnc_commodity_table_get_quotable_commodities"
|
||||
'((<gnc:commodity-table*> table)
|
||||
((<gw:mchars> caller-owned const) namespace))
|
||||
"Return a list of all the quotable commodities in a given namespace in the table.")
|
||||
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:account-separator-char
|
||||
|
@ -119,6 +119,38 @@ gnc_account_dom_tree_create(Account *act, gboolean exporting)
|
||||
if(kf)
|
||||
{
|
||||
xmlNodePtr kvpnode = kvp_frame_to_dom_tree(act_slots_string, kf);
|
||||
#if ((GNUCASH_MAJOR_VERSION == 1) && (GNUCASH_MINOR_VERSION < 10))
|
||||
{
|
||||
/* Temporary backwards compatability hack. Create kvp slot
|
||||
* information for the stock quote data in case the user has
|
||||
* to fall back to the production code. */
|
||||
xmlNodePtr slot_node, val_node;
|
||||
gnc_commodity *com;
|
||||
const gchar *tz;
|
||||
|
||||
com = xaccAccountGetCommodity(act);
|
||||
if (com &&
|
||||
!gnc_commodity_is_iso(com) &&
|
||||
gnc_commodity_get_quote_flag(com)) {
|
||||
if (!kvpnode)
|
||||
kvpnode= xmlNewNode(NULL, act_slots_string);
|
||||
|
||||
slot_node = xmlNewChild(kvpnode, NULL, "slot", NULL);
|
||||
xmlNewTextChild(slot_node, NULL, "slot:key", "old-price-source");
|
||||
val_node = xmlNewTextChild(slot_node, NULL, "slot:value",
|
||||
gnc_commodity_get_quote_source(com));
|
||||
xmlSetProp(val_node, "type", "string");
|
||||
|
||||
tz = gnc_commodity_get_quote_tz(com);
|
||||
if (tz) {
|
||||
slot_node = xmlNewChild(kvpnode, NULL, "slot", NULL);
|
||||
xmlNewTextChild(slot_node, NULL, "slot:key", "old-quote-tz");
|
||||
val_node = xmlNewTextChild(slot_node, NULL, "slot:value", tz);
|
||||
xmlSetProp(val_node, "type", "string");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(kvpnode)
|
||||
{
|
||||
xmlAddChild(ret, kvpnode);
|
||||
|
@ -56,10 +56,14 @@ const gchar *commodity_version_string = "2.0.0";
|
||||
#define cmdty_name "cmdty:name"
|
||||
#define cmdty_xcode "cmdty:xcode"
|
||||
#define cmdty_fraction "cmdty:fraction"
|
||||
#define cmdty_get_quotes "cmdty:get_quotes"
|
||||
#define cmdty_quote_source "cmdty:quote_source"
|
||||
#define cmdty_quote_tz "cmdty:quote_tz"
|
||||
|
||||
xmlNodePtr
|
||||
gnc_commodity_dom_tree_create(const gnc_commodity *com)
|
||||
{
|
||||
const char *string;
|
||||
xmlNodePtr ret;
|
||||
|
||||
ret = xmlNewNode(NULL, gnc_commodity_string);
|
||||
@ -88,6 +92,15 @@ gnc_commodity_dom_tree_create(const gnc_commodity *com)
|
||||
xmlAddChild(ret, int_to_dom_tree(cmdty_fraction,
|
||||
gnc_commodity_get_fraction(com)));
|
||||
|
||||
if (gnc_commodity_get_quote_flag(com))
|
||||
xmlNewChild(ret, NULL, cmdty_get_quotes, NULL);
|
||||
string = gnc_commodity_get_quote_source(com);
|
||||
if (string)
|
||||
xmlAddChild(ret, text_to_dom_tree(cmdty_quote_source, string));
|
||||
string = gnc_commodity_get_quote_tz(com);
|
||||
if (string)
|
||||
xmlAddChild(ret, text_to_dom_tree(cmdty_quote_tz, string));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -104,6 +117,8 @@ struct com_char_handler com_handlers[] = {
|
||||
{ cmdty_id, gnc_commodity_set_mnemonic },
|
||||
{ cmdty_name, gnc_commodity_set_fullname },
|
||||
{ cmdty_xcode, gnc_commodity_set_exchange_code },
|
||||
{ cmdty_quote_source, gnc_commodity_set_quote_source },
|
||||
{ cmdty_quote_tz, gnc_commodity_set_quote_tz },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@ -122,6 +137,14 @@ set_commodity_value(xmlNodePtr node, gnc_commodity* com)
|
||||
}
|
||||
xmlFree (string);
|
||||
}
|
||||
else if(safe_strcmp(node->name, cmdty_get_quotes) == 0)
|
||||
{
|
||||
char *string;
|
||||
|
||||
string = xmlNodeGetContent (node->xmlChildrenNode);
|
||||
gnc_commodity_set_quote_flag(com, TRUE);
|
||||
xmlFree (string);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct com_char_handler *mark;
|
||||
|
@ -871,7 +871,7 @@ readAccInfo(int fd, Account *acc, int token) {
|
||||
if ((acc_type == STOCK) || (acc_type == MUTUAL)) {
|
||||
const char *tmp = readString( fd, token );
|
||||
if(NULL == tmp) return(FALSE);
|
||||
if(strlen(tmp) > 0) xaccAccountSetPriceSrc(acc, tmp);
|
||||
if(strlen(tmp) > 0) dxaccAccountSetPriceSrc(acc, tmp);
|
||||
free((char *) tmp);
|
||||
}
|
||||
return(TRUE);
|
||||
|
@ -713,6 +713,10 @@ gnc_session_load_from_xml_file_v2(GNCSession *session)
|
||||
/* Mark the book as saved */
|
||||
gnc_book_mark_saved (book);
|
||||
|
||||
/* fix price quote sources */
|
||||
xaccGroupScrubQuoteSources (gnc_book_get_group(book),
|
||||
gnc_book_get_commodity_table(book));
|
||||
|
||||
/* Fix account and transaction commodities */
|
||||
xaccGroupScrubCommodities (gnc_book_get_group(book));
|
||||
|
||||
|
@ -1489,6 +1489,11 @@ xaccAccountSetCommodity (Account * acc, gnc_commodity * com)
|
||||
}
|
||||
acc->core_dirty = TRUE;
|
||||
xaccAccountCommitEdit(acc);
|
||||
if (gnc_commodity_is_iso(com)) {
|
||||
/* compatability hack - Gnucash 1.8 gets currency quotes when a
|
||||
non-default currency is assigned to an account. */
|
||||
gnc_commodity_set_quote_flag(com, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -2894,7 +2899,7 @@ xaccAccountSetLastNum (Account *account, const char *num)
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccAccountSetPriceSrc(Account *acc, const char *src)
|
||||
dxaccAccountSetPriceSrc(Account *acc, const char *src)
|
||||
{
|
||||
if(!acc) return;
|
||||
|
||||
@ -2917,7 +2922,7 @@ xaccAccountSetPriceSrc(Account *acc, const char *src)
|
||||
\********************************************************************/
|
||||
|
||||
const char*
|
||||
xaccAccountGetPriceSrc(Account *acc)
|
||||
dxaccAccountGetPriceSrc(Account *acc)
|
||||
{
|
||||
GNCAccountType t;
|
||||
if(!acc) return NULL;
|
||||
@ -2935,10 +2940,9 @@ xaccAccountGetPriceSrc(Account *acc)
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccAccountSetQuoteTZ(Account *acc, const char *tz)
|
||||
dxaccAccountSetQuoteTZ(Account *acc, const char *tz)
|
||||
{
|
||||
if(!acc) return;
|
||||
if(!tz) return;
|
||||
|
||||
xaccAccountBeginEdit(acc);
|
||||
{
|
||||
@ -2947,7 +2951,7 @@ xaccAccountSetQuoteTZ(Account *acc, const char *tz)
|
||||
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY)) {
|
||||
kvp_frame_set_slot_nc(acc->kvp_data,
|
||||
"old-quote-tz",
|
||||
kvp_value_new_string(tz));
|
||||
tz ? kvp_value_new_string(tz) : NULL);
|
||||
mark_account (acc);
|
||||
}
|
||||
}
|
||||
@ -2959,7 +2963,7 @@ xaccAccountSetQuoteTZ(Account *acc, const char *tz)
|
||||
\********************************************************************/
|
||||
|
||||
const char*
|
||||
xaccAccountGetQuoteTZ(Account *acc)
|
||||
dxaccAccountGetQuoteTZ(Account *acc)
|
||||
{
|
||||
GNCAccountType t;
|
||||
if(!acc) return NULL;
|
||||
|
@ -232,16 +232,20 @@ const char * xaccAccountGetLastNum (Account *account);
|
||||
*/
|
||||
char * xaccAccountGetFullName (Account *account, const char separator);
|
||||
|
||||
/** The xaccAccountSetPriceSrc() and xaccAccountGetPriceSrc() routines
|
||||
are used to get and set a string that identifies the Finance::Quote
|
||||
backend that should be used to retrieve online prices. See
|
||||
price-quotes.scm for more information.*/
|
||||
void xaccAccountSetPriceSrc (Account *account, const char *src);
|
||||
/** The xaccAccountSetPriceSrc() and xaccAccountGetPriceSrc() routines
|
||||
are used to get and set a string that identifies the Finance::Quote
|
||||
backend that should be used to retrieve online prices. See
|
||||
price-quotes.scm for more information.*/
|
||||
const char * xaccAccountGetPriceSrc (Account *account);
|
||||
/** Set a string that identifies the Finance::Quote backend that
|
||||
* should be used to retrieve online prices. See price-quotes.scm
|
||||
* for more information
|
||||
*
|
||||
* @deprecated Price quote information is now stored on the
|
||||
* commodity, not the account. */
|
||||
void dxaccAccountSetPriceSrc (Account *account, const char *src);
|
||||
/** Get a string that identifies the Finance::Quote backend that
|
||||
* should be used to retrieve online prices. See price-quotes.scm
|
||||
* for more information.
|
||||
*
|
||||
* @deprecated Price quote information is now stored on the
|
||||
* commodity, not the account. */
|
||||
const char * dxaccAccountGetPriceSrc (Account *account);
|
||||
|
||||
/** Returns a per-account flag: Prior to reconciling an account which
|
||||
charges or pays interest, this flag tells whether to prompt the
|
||||
@ -717,18 +721,20 @@ void DxaccAccountSetCurrencySCU (Account *account, int frac);
|
||||
* it. */
|
||||
int DxaccAccountGetCurrencySCU (Account *account);
|
||||
|
||||
/** xaccAccountGetQuoteTZ() and xaccAccountSetQuoteTZ() set the
|
||||
timezone to be used when interpreting the results from a given
|
||||
Finance::Quote backend. Unfortunately, the upstream sources don't
|
||||
label their output, so the user has to specify this bit.
|
||||
|
||||
@deprecated Since prices are not going to be stored in the accounts in the
|
||||
future, and since the whole commodities infrastructure is changing
|
||||
radically as we speak, this interface is not long for this
|
||||
world. */
|
||||
void xaccAccountSetQuoteTZ (Account *account, const char *tz);
|
||||
/** @deprecated */
|
||||
const char * xaccAccountGetQuoteTZ (Account *account);
|
||||
/** Set the timezone to be used when interpreting the results from a
|
||||
* given Finance::Quote backend. Unfortunately, the upstream sources
|
||||
* don't label their output, so the user has to specify this bit.
|
||||
*
|
||||
* @deprecated Price quote information is now stored on the
|
||||
* commodity, not the account. */
|
||||
void dxaccAccountSetQuoteTZ (Account *account, const char *tz);
|
||||
/** Get the timezone to be used when interpreting the results from a
|
||||
* given Finance::Quote backend. Unfortunately, the upstream sources
|
||||
* don't label their output, so the user has to specify this bit.
|
||||
*
|
||||
* @deprecated Price quote information is now stored on the
|
||||
* commodity, not the account. */
|
||||
const char * dxaccAccountGetQuoteTZ (Account *account);
|
||||
/**@}*/
|
||||
|
||||
|
||||
|
@ -571,6 +571,67 @@ xaccGroupScrubCommodities (AccountGroup *group)
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
static gboolean
|
||||
check_quote_source (gnc_commodity *com, gpointer data)
|
||||
{
|
||||
gboolean *commodity_has_quote_src = (gboolean *)data;
|
||||
if (com && !gnc_commodity_is_iso(com))
|
||||
*commodity_has_quote_src |= gnc_commodity_get_quote_flag(com);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
move_quote_source (Account *account, gpointer data)
|
||||
{
|
||||
gnc_commodity *com;
|
||||
gboolean new_style = GPOINTER_TO_INT(data);
|
||||
const char *source, *tz;
|
||||
|
||||
com = xaccAccountGetCommodity(account);
|
||||
if (!com)
|
||||
return NULL;
|
||||
|
||||
if (!new_style) {
|
||||
source = dxaccAccountGetPriceSrc(account);
|
||||
if (!source || !*source)
|
||||
return NULL;
|
||||
tz = dxaccAccountGetQuoteTZ(account);
|
||||
|
||||
PINFO("to %8s from %s", gnc_commodity_get_mnemonic(com),
|
||||
xaccAccountGetName(account));
|
||||
gnc_commodity_set_quote_flag(com, TRUE);
|
||||
gnc_commodity_set_quote_source(com, source);
|
||||
gnc_commodity_set_quote_tz(com, tz);
|
||||
}
|
||||
|
||||
dxaccAccountSetPriceSrc(account, NULL);
|
||||
dxaccAccountSetQuoteTZ(account, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xaccGroupScrubQuoteSources (AccountGroup *group, gnc_commodity_table *table)
|
||||
{
|
||||
ENTER(" ");
|
||||
gboolean new_style = FALSE;
|
||||
|
||||
if (!group || !table) {
|
||||
LEAVE("Oops")
|
||||
return;
|
||||
}
|
||||
|
||||
gnc_commodity_table_foreach_commodity (table, check_quote_source, &new_style);
|
||||
|
||||
xaccAccountGroupBeginEdit (group);
|
||||
xaccGroupForEachAccount (group, move_quote_source,
|
||||
GINT_TO_POINTER(new_style), TRUE);
|
||||
xaccAccountGroupCommitEdit (group);
|
||||
LEAVE("Migration done");
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
Account *
|
||||
xaccScrubUtilityGetOrMakeAccount (AccountGroup *root, gnc_commodity * currency,
|
||||
const char *name_root)
|
||||
|
@ -105,4 +105,19 @@ void xaccAccountScrubCommodity (Account *account);
|
||||
* of all accounts & transactions in the group. */
|
||||
void xaccGroupScrubCommodities (AccountGroup *group);
|
||||
|
||||
/** This routine will migrate the information about price quote
|
||||
* sources from the account data structures to the commodity data
|
||||
* structures. It first checks to see if this is necessary since,
|
||||
* for the time being, the quote information will still be written
|
||||
* out as part of the account. Just in case anyone needs to fall
|
||||
* back from CVS to a production version of code.
|
||||
*
|
||||
* @param group A pointer to the account group containing all
|
||||
* accounts in the current book.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the current
|
||||
* book.
|
||||
*/
|
||||
void xaccGroupScrubQuoteSources (AccountGroup *group, gnc_commodity_table *table);
|
||||
|
||||
#endif /* XACC_SCRUB_H */
|
||||
|
@ -51,6 +51,10 @@ struct gnc_commodity_s {
|
||||
int fraction;
|
||||
char * unique_name;
|
||||
gint16 mark; /* user-defined mark, handy for traversals */
|
||||
|
||||
gboolean quote_flag; /* user wants price quotes */
|
||||
char * quote_source; /* current/old source of quotes */
|
||||
char * quote_tz;
|
||||
};
|
||||
|
||||
struct gnc_commodity_namespace_s {
|
||||
@ -116,12 +120,10 @@ gnc_commodity_destroy(gnc_commodity * cm)
|
||||
{
|
||||
if(!cm) return;
|
||||
|
||||
/* Set at creation */
|
||||
g_free(cm->fullname);
|
||||
cm->fullname = NULL;
|
||||
|
||||
g_free(cm->printname);
|
||||
cm->printname = NULL;
|
||||
|
||||
g_free(cm->namespace);
|
||||
cm->namespace = NULL;
|
||||
|
||||
@ -131,6 +133,17 @@ gnc_commodity_destroy(gnc_commodity * cm)
|
||||
g_free(cm->mnemonic);
|
||||
cm->mnemonic = NULL;
|
||||
|
||||
/* Set through accessor functions */
|
||||
g_free(cm->quote_source);
|
||||
cm->quote_source = NULL;
|
||||
|
||||
g_free(cm->quote_tz);
|
||||
cm->quote_tz = NULL;
|
||||
|
||||
/* Automatically generated */
|
||||
g_free(cm->printname);
|
||||
cm->printname = NULL;
|
||||
|
||||
g_free(cm->unique_name);
|
||||
cm->unique_name = NULL;
|
||||
|
||||
@ -232,6 +245,41 @@ gnc_commodity_get_mark(const gnc_commodity * cm)
|
||||
return cm->mark;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_get_quote_flag
|
||||
********************************************************************/
|
||||
|
||||
gboolean
|
||||
gnc_commodity_get_quote_flag(const gnc_commodity *cm)
|
||||
{
|
||||
if(!cm) return FALSE;
|
||||
return (cm->quote_flag);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_get_quote_source
|
||||
********************************************************************/
|
||||
|
||||
const char*
|
||||
gnc_commodity_get_quote_source(const gnc_commodity *cm)
|
||||
{
|
||||
if(!cm) return NULL;
|
||||
if (!cm->quote_source && gnc_commodity_is_iso(cm))
|
||||
return "CURRENCY";
|
||||
return cm->quote_source;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_get_quote_tz
|
||||
********************************************************************/
|
||||
|
||||
const char*
|
||||
gnc_commodity_get_quote_tz(const gnc_commodity *cm)
|
||||
{
|
||||
if(!cm) return NULL;
|
||||
return cm->quote_tz;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_set_mnemonic
|
||||
********************************************************************/
|
||||
@ -309,7 +357,7 @@ gnc_commodity_set_fraction(gnc_commodity * cm, int fraction)
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_get_mark
|
||||
* gnc_commodity_set_mark
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
@ -319,6 +367,65 @@ gnc_commodity_set_mark(gnc_commodity * cm, gint16 mark)
|
||||
cm->mark = mark;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_set_quote_flag
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_commodity_set_quote_flag(gnc_commodity *cm, const gboolean flag)
|
||||
{
|
||||
ENTER ("(cm=%p, flag=%d)", cm, flag);
|
||||
|
||||
if(!cm) return;
|
||||
cm->quote_flag = flag;
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_set_quote_source
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_commodity_set_quote_source(gnc_commodity *cm, const char *src)
|
||||
{
|
||||
ENTER ("(cm=%p, src=%s)", cm, src);
|
||||
|
||||
if(!cm) return;
|
||||
if (cm->quote_source) {
|
||||
g_free(cm->quote_source);
|
||||
cm->quote_source = NULL;
|
||||
}
|
||||
|
||||
if (src && *src)
|
||||
cm->quote_source = g_strdup(src);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_set_quote_tz
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz)
|
||||
{
|
||||
ENTER ("(cm=%p, tz=%s)", cm, tz);
|
||||
|
||||
if(!cm) return;
|
||||
|
||||
if (cm->quote_tz) {
|
||||
g_free(cm->quote_tz);
|
||||
cm->quote_tz = NULL;
|
||||
}
|
||||
|
||||
if (tz && *tz)
|
||||
cm->quote_tz = g_strdup(tz);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_equiv
|
||||
* are two commodities the same?
|
||||
@ -553,7 +660,9 @@ gnc_commodity_table_insert(gnc_commodity_table * table,
|
||||
gnc_commodity_set_fraction (c, gnc_commodity_get_fraction (comm));
|
||||
gnc_commodity_set_exchange_code (c,
|
||||
gnc_commodity_get_exchange_code (comm));
|
||||
|
||||
gnc_commodity_set_quote_flag (c, gnc_commodity_get_quote_flag (comm));
|
||||
gnc_commodity_set_quote_source (c, gnc_commodity_get_quote_source (comm));
|
||||
gnc_commodity_set_quote_tz (c, gnc_commodity_get_quote_tz (comm));
|
||||
gnc_commodity_destroy (comm);
|
||||
|
||||
return c;
|
||||
@ -602,7 +711,7 @@ gnc_commodity_table_remove(gnc_commodity_table * table,
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_table_has_namespace
|
||||
* see if any commodities in the namespace exist
|
||||
* see if the commodities namespace exists. May have zero commodities.
|
||||
********************************************************************/
|
||||
|
||||
int
|
||||
@ -690,16 +799,65 @@ gnc_commodity_table_get_commodities(const gnc_commodity_table * table,
|
||||
{
|
||||
gnc_commodity_namespace * ns = NULL;
|
||||
|
||||
if(table) {
|
||||
ns = g_hash_table_lookup(table->table, (gpointer)namespace);
|
||||
}
|
||||
if (!table)
|
||||
return NULL;
|
||||
|
||||
ns = g_hash_table_lookup(table->table, (gpointer)namespace);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
|
||||
if(ns) {
|
||||
return g_hash_table_values(ns->table);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_table_get_quotable_commodities
|
||||
* list commodities in a given namespace that get price quotes
|
||||
********************************************************************/
|
||||
|
||||
static void
|
||||
get_quotables_helper1(gpointer key, gpointer value, gpointer data)
|
||||
{
|
||||
gnc_commodity *comm = value;
|
||||
GList ** l = data;
|
||||
|
||||
if (!comm->quote_flag)
|
||||
return;
|
||||
*l = g_list_prepend(*l, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_quotables_helper2 (gnc_commodity *comm, gpointer data)
|
||||
{
|
||||
GList ** l = data;
|
||||
|
||||
if (!comm->quote_flag)
|
||||
return TRUE;
|
||||
*l = g_list_prepend(*l, comm);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GList *
|
||||
gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table,
|
||||
const char * namespace)
|
||||
{
|
||||
gnc_commodity_namespace * ns = NULL;
|
||||
GList * l = NULL;
|
||||
|
||||
ENTER("table=%p, namespace=%s", table, namespace);
|
||||
if (!table)
|
||||
return NULL;
|
||||
|
||||
if (namespace && *namespace) {
|
||||
ns = g_hash_table_lookup(table->table, (gpointer)namespace);
|
||||
DEBUG("ns=%p", ns);
|
||||
if (ns)
|
||||
g_hash_table_foreach(ns->table, &get_quotables_helper1, (gpointer) &l);
|
||||
} else {
|
||||
gnc_commodity_table_foreach_commodity(table, get_quotables_helper2,
|
||||
(gpointer) &l);
|
||||
}
|
||||
LEAVE("list head %p", l);
|
||||
return l;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
@ -764,29 +922,6 @@ gnc_commodity_table_delete_namespace(gnc_commodity_table * table,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_commodity_table_remove_non_iso (gnc_commodity_table *t)
|
||||
{
|
||||
GList *namespaces;
|
||||
GList *node;
|
||||
|
||||
if (!t) return;
|
||||
|
||||
namespaces = gnc_commodity_table_get_namespaces (t);
|
||||
|
||||
for (node = namespaces; node; node = node->next)
|
||||
{
|
||||
char *ns = node->data;
|
||||
|
||||
if (safe_strcmp (ns, GNC_COMMODITY_NS_ISO) == 0)
|
||||
continue;
|
||||
|
||||
gnc_commodity_table_delete_namespace (t, ns);
|
||||
}
|
||||
|
||||
g_list_free (namespaces);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_commodity_table_foreach_commodity
|
||||
* call user-defined function once for every commodity in every
|
||||
@ -819,7 +954,7 @@ iter_namespace (gpointer key, gpointer value, gpointer user_data)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_commodity_table_foreach_commodity (gnc_commodity_table * tbl,
|
||||
gnc_commodity_table_foreach_commodity (const gnc_commodity_table * tbl,
|
||||
gboolean (*f)(gnc_commodity *, gpointer),
|
||||
gpointer user_data)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/********************************************************************
|
||||
* gnc-commodity.h -- api for tradable commodities (incl. currency) *
|
||||
* gnc-commodity.h -- API for tradable commodities (incl. currency) *
|
||||
* Copyright (C) 2000 Bill Gribble *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -21,12 +21,39 @@
|
||||
* *
|
||||
*******************************************************************/
|
||||
|
||||
/** @addtogroup Engine
|
||||
@{ */
|
||||
/** @file gnc-commodity.h
|
||||
*
|
||||
* This file contains the functions to manipulate two different
|
||||
* objects. These are an object of type gnc_commodity, and an object
|
||||
* of type gnc_commodity_table. The gnc_commodity object corresponds
|
||||
* one-to-one with some type of tradable commodity; a currency, a
|
||||
* stock, a mutual fund, etc. The gnc_commodity_table object is a
|
||||
* database containing objects of type gnc_commodity.
|
||||
*
|
||||
* @brief Commodity handling public routines
|
||||
* @author Copyright (C) 2000 Bill Gribble
|
||||
* @author Copyright (C) 2001 Linas Vepstas <linas@linas.org>
|
||||
*/
|
||||
|
||||
#ifndef GNC_COMMODITY_H
|
||||
#define GNC_COMMODITY_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "gnc-engine.h"
|
||||
|
||||
/** The commodity namespace definitions are used to tag a commodity by
|
||||
* its type, or a stocks by the exchange where it is traded.
|
||||
*
|
||||
* The LEGACY name is only used by the file i/o routines, and is
|
||||
* converted to another commodity namespace before it is seen by the
|
||||
* rest of the system. The ISO namespace represents currencies.
|
||||
* With the exception of the NASDAQ namespace (which is used once in
|
||||
* the binary importer) the rest of the namespace declarations are
|
||||
* only used to populate an option menu in the commodity selection
|
||||
* window.
|
||||
*/
|
||||
#define GNC_COMMODITY_NS_LEGACY "GNC_LEGACY_CURRENCIES"
|
||||
#define GNC_COMMODITY_NS_ISO "ISO4217"
|
||||
#define GNC_COMMODITY_NS_NASDAQ "NASDAQ"
|
||||
@ -36,59 +63,373 @@
|
||||
#define GNC_COMMODITY_NS_AMEX "AMEX"
|
||||
#define GNC_COMMODITY_NS_ASX "ASX"
|
||||
|
||||
/* gnc_commodity functions */
|
||||
|
||||
|
||||
/** @name Commodity Creation */
|
||||
/** @{ */
|
||||
|
||||
/** Create a new commodity. This function allocates a new commodity
|
||||
* data structure, populates it with the data provided, and then
|
||||
* generates the dynamic names that exist as part of a commodity.
|
||||
*
|
||||
* @note This function does not check to see if the commodity exists
|
||||
* before adding a new commodity.
|
||||
*
|
||||
* @param fullname The complete name of this commodity. E.G. "Acme
|
||||
* Systems, Inc."
|
||||
*
|
||||
* @param namespace An aggregation of commodities. E.G. ISO4217,
|
||||
* Nasdaq, Downbelow, etc.
|
||||
*
|
||||
* @param mnemonic An abbreviation for this stock. For publicly
|
||||
* traced stocks, this field should contain the stock ticker
|
||||
* symbol. This field is used to get online price quotes, so it must
|
||||
* match the stock ticker symbol used by the exchange where you want
|
||||
* to get automatic stock quote updates. E.G. ACME, ACME.US, etc.
|
||||
*
|
||||
* @param exchange_code A string containing the CUSIP code or similar
|
||||
* UNIQUE code for this commodity. The stock ticker is NOT
|
||||
* appropriate.
|
||||
*
|
||||
* @param fraction The smallest division of this commodity
|
||||
* allowed. I.E. If this is 1, then the commodity must be traded in
|
||||
* whole units; if 100 then the commodity may be traded in 0.01
|
||||
* units, etc.
|
||||
*
|
||||
* @return A pointer to the new commodity.
|
||||
*/
|
||||
gnc_commodity * gnc_commodity_new(const char * fullname,
|
||||
const char * namespace,
|
||||
const char * mnemonic,
|
||||
const char * exchange_code,
|
||||
int fraction);
|
||||
|
||||
/** Destroy a commodity. Release all memory attached to this data structure.
|
||||
* @note This function does not (can not) check to see if the
|
||||
* commodity is referenced anywhere.
|
||||
* @param cm The commodity to destroy.
|
||||
*/
|
||||
void gnc_commodity_destroy(gnc_commodity * cm);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
/** @name Commodity Accessor Routines - Get */
|
||||
/** @{ */
|
||||
|
||||
/** Retrieve the mnemonic for the specified commodity. This will be a
|
||||
* pointer to a null terminated string of the form "ACME", "QWER",
|
||||
* etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the mnemonic for this commodity. This string
|
||||
* is owned by the engine and should not be freed by the caller.
|
||||
*/
|
||||
const char * gnc_commodity_get_mnemonic(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the namespace for the specified commodity. This will be
|
||||
* a pointer to a null terminated string of the form "AMEX",
|
||||
* "NASDAQ", etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the namespace for this commodity. This string
|
||||
* is owned by the engine and should not be freed by the caller.
|
||||
*/
|
||||
const char * gnc_commodity_get_namespace(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the full name for the specified commodity. This will be
|
||||
* a pointer to a null terminated string of the form "Acme Systems,
|
||||
* Inc.", etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the full name for this commodity. This string
|
||||
* is owned by the engine and should not be freed by the caller.
|
||||
*/
|
||||
const char * gnc_commodity_get_fullname(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the 'print' name for the specified commodity. This will
|
||||
* be a pointer to a null terminated string of the form "Acme
|
||||
* Systems, Inc. (ACME)", etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the print name for this commodity. This
|
||||
* string is owned by the engine and should not be freed by the
|
||||
* caller.
|
||||
*/
|
||||
const char * gnc_commodity_get_printname(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the 'exchange code' for the specified commodity. This
|
||||
* will be a pointer to a null terminated string of the form
|
||||
* "AXQ14728", etc. This field is often used when presenting
|
||||
* information to the user.
|
||||
*
|
||||
* @note This is a unique code that specifies a particular item or
|
||||
* set of shares of a commodity, not a code that specifies a stock
|
||||
* exchange. That is the namespace field.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the exchange code for this commodity. This
|
||||
* string is owned by the engine and should not be freed by the
|
||||
* caller.
|
||||
*/
|
||||
const char * gnc_commodity_get_exchange_code(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the 'unique' name for the specified commodity. This will
|
||||
* be a pointer to a null terminated string of the form "AMEX::ACME",
|
||||
* etc. This field is often used when performing comparisons or
|
||||
* other functions invisible to the user.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the 'unique' name for this commodity. This
|
||||
* string is owned by the engine and should not be freed by the
|
||||
* caller.
|
||||
*/
|
||||
const char * gnc_commodity_get_unique_name(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the fraction for the specified commodity. This will be
|
||||
* an integer value specifying the number of fractional units that
|
||||
* one of these commodities can be divided into. Should always be a
|
||||
* power of 10.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return The number of fractional units that one of these
|
||||
* commodities can be divided into.
|
||||
*/
|
||||
int gnc_commodity_get_fraction(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the 'mark' field for the specified commodity.
|
||||
*
|
||||
* @note This is a private field used by the Postgres back end.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return The value of the mark field.
|
||||
*/
|
||||
gint16 gnc_commodity_get_mark(const gnc_commodity * cm);
|
||||
|
||||
/** Retrieve the automatic price quote flag for the specified
|
||||
* commodity. This flag indicates whether stock quotes should be
|
||||
* retrieved for the specified stock.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return TRUE if quotes should be pulled for this commodity, FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
gboolean gnc_commodity_get_quote_flag(const gnc_commodity *cm);
|
||||
|
||||
/** Retrieve the automatic price quote source for the specified
|
||||
* commodity. This will be a pointer to a null terminated string of
|
||||
* the form "Yahoo (Asia)", etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the price quote source for this commodity.
|
||||
* This string is owned by the engine and should not be freed by the
|
||||
* caller.
|
||||
*/
|
||||
const char* gnc_commodity_get_quote_source(const gnc_commodity *cm);
|
||||
|
||||
/** Retrieve the automatic price quote timezone for the specified
|
||||
* commodity. This will be a pointer to a null terminated string of
|
||||
* the form "America/New_York", etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the price quote timezone for this commodity.
|
||||
* This string is owned by the engine and should not be freed by the
|
||||
* caller.
|
||||
*/
|
||||
const char* gnc_commodity_get_quote_tz(const gnc_commodity *cm);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
/** @name Commodity Accessor Routines - Set */
|
||||
/** @{ */
|
||||
|
||||
/** Set the mnemonic for the specified commodity. This should be a
|
||||
* pointer to a null terminated string of the form "ACME", "QWER",
|
||||
* etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @param mnemonic A pointer to the mnemonic for this commodity.
|
||||
* This string belongs to the caller and will be duplicated by the
|
||||
* engine.
|
||||
*/
|
||||
void gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic);
|
||||
|
||||
/** Set the namespace for the specified commodity. This should be a
|
||||
* pointer to a null terminated string of the form "AMEX", "NASDAQ",
|
||||
* etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @param namespace A pointer to the namespace for this commodity.
|
||||
* This string belongs to the caller and will be duplicated by the
|
||||
* engine.
|
||||
*/
|
||||
void gnc_commodity_set_namespace(gnc_commodity * cm, const char * namespace);
|
||||
|
||||
/** Set the full name for the specified commodity. This should be
|
||||
* a pointer to a null terminated string of the form "Acme Systems,
|
||||
* Inc.", etc.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @param fullname A pointer to the full name for this commodity.
|
||||
* This string belongs to the caller and will be duplicated by the
|
||||
* engine.
|
||||
*/
|
||||
void gnc_commodity_set_fullname(gnc_commodity * cm, const char * fullname);
|
||||
|
||||
/** Set the 'exchange code' for the specified commodity. This should
|
||||
* be a pointer to a null terminated string of the form "AXQ14728",
|
||||
* etc.
|
||||
*
|
||||
* @note This is a unique code that specifies a particular item or
|
||||
* set of shares of a commodity, not a code that specifies a stock
|
||||
* exchange. That is the namespace field.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @param exchange_code A pointer to the full name for this commodity. This
|
||||
* string belongs to the caller and will be duplicated by the engine.
|
||||
*/
|
||||
void gnc_commodity_set_exchange_code(gnc_commodity * cm,
|
||||
const char * exchange_code);
|
||||
|
||||
/** Set the fraction for the specified commodity. This should be
|
||||
* an integer value specifying the number of fractional units that
|
||||
* one of these commodities can be divided into. Should always be a
|
||||
* power of 10.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @param smallest_fraction The number of fractional units that one of
|
||||
* these commodities can be divided into.
|
||||
*/
|
||||
void gnc_commodity_set_fraction(gnc_commodity * cm, int smallest_fraction);
|
||||
|
||||
/** Set the 'mark' field for the specified commodity.
|
||||
*
|
||||
* @note This is a private field used by the Postgres back end.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @param mark The new value of the mark field.
|
||||
*/
|
||||
void gnc_commodity_set_mark(gnc_commodity * cm, gint16 mark);
|
||||
|
||||
/** The gnc_commodity_equiv() routine returns TRUE if the two commodities are
|
||||
* equivalent. Commodities are equivalent if they have the same namespace
|
||||
* and mnemonic. Equivalent commodities my belong to different exchanges,
|
||||
* may have different fullnames, and may have different fractionals.
|
||||
/** Set the automatic price quote flag for the specified commodity.
|
||||
* This flag indicates whether stock quotes should be retrieved for
|
||||
* the specified stock.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @param flag TRUE if quotes should be pulled for this commodity, FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
void gnc_commodity_set_quote_flag(gnc_commodity *cm, const gboolean flag);
|
||||
|
||||
/** Set the automatic price quote source for the specified commodity.
|
||||
* This should be a pointer to a null terminated string of the form
|
||||
* "Yahoo (Asia)", etc. Legal values can be found in the
|
||||
* quote_sources array in the file gnc-ui-util.c.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the price quote source for this commodity.
|
||||
* This string belongs to the caller and will be duplicated by the
|
||||
* engine.
|
||||
*/
|
||||
void gnc_commodity_set_quote_source(gnc_commodity *cm, const char *src);
|
||||
|
||||
/** Set the automatic price quote timezone for the specified
|
||||
* commodity. This should be a pointer to a null terminated string
|
||||
* of the form "America/New_York", etc. Legal values can be found in
|
||||
* the known_timezones array in the file dialog-util.c.
|
||||
*
|
||||
* @param cm A pointer to a commodity data structure.
|
||||
*
|
||||
* @return A pointer to the price quote timezone for this commodity.
|
||||
* This string belongs to the caller and will be duplicated by the
|
||||
* engine.
|
||||
*/
|
||||
void gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
/** @name Commodity Comparison */
|
||||
/** @{ */
|
||||
|
||||
/** This routine returns TRUE if the two commodities are equivalent.
|
||||
* Commodities are equivalent if they have the same namespace and
|
||||
* mnemonic. Equivalent commodities may belong to different
|
||||
* exchanges, may have different fullnames, and may have different
|
||||
* fractions.
|
||||
*/
|
||||
gboolean gnc_commodity_equiv(const gnc_commodity * a, const gnc_commodity * b);
|
||||
|
||||
/** The gnc_commodity_equal() routine returns TRUE if the two commodities are
|
||||
* equal. Commodities are equal if they have the same namespace, mnemonic,
|
||||
* fullname, exchange and fraction.
|
||||
/** This routine returns TRUE if the two commodities are equal.
|
||||
* Commodities are equal if they have the same namespace, mnemonic,
|
||||
* fullname, exchange private code and fraction.
|
||||
*/
|
||||
gboolean gnc_commodity_equal(const gnc_commodity * a, const gnc_commodity * b);
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @name Currency Checks */
|
||||
/** @{ */
|
||||
|
||||
/** Checks to see if the specified commodity namespace is the
|
||||
* namespace for ISO 4217 currencies.
|
||||
*
|
||||
* @param cm The string to check.
|
||||
*
|
||||
* @return TRUE if the string indicates an ISO currency, FALSE otherwise. */
|
||||
gboolean gnc_commodity_namespace_is_iso(const char *namespace);
|
||||
gboolean gnc_commodity_is_iso(const gnc_commodity * comm);
|
||||
|
||||
/** Checks to see if the specified commodity is an ISO 4217 recognized currency.
|
||||
*
|
||||
* @param cm The commodity to check.
|
||||
*
|
||||
* @return TRUE if the commodity represents a currency, FALSE otherwise. */
|
||||
gboolean gnc_commodity_is_iso(const gnc_commodity * cm);
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @name Commodity Table Creation */
|
||||
/** @{ */
|
||||
|
||||
/* gnc_commodity_table functions : operate on a database of commodity
|
||||
* info */
|
||||
|
||||
gnc_commodity_table * gnc_commodity_table_new(void);
|
||||
void gnc_commodity_table_destroy(gnc_commodity_table * table);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
/** @name Commodity Table Comparison */
|
||||
/** @{ */
|
||||
gboolean gnc_commodity_table_equal(gnc_commodity_table *t_1,
|
||||
gnc_commodity_table *t_2);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
/** @name Commodity Table Lookup functions */
|
||||
/** @{ */
|
||||
gnc_commodity * gnc_commodity_table_lookup(const gnc_commodity_table * table,
|
||||
const char * namespace,
|
||||
const char * mnemonic);
|
||||
@ -98,38 +439,169 @@ gnc_commodity_table_lookup_unique(const gnc_commodity_table *table,
|
||||
gnc_commodity * gnc_commodity_table_find_full(const gnc_commodity_table * t,
|
||||
const char * namespace,
|
||||
const char * fullname);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
/** @name Commodity Table Maintenance functions */
|
||||
/** @{ */
|
||||
|
||||
/** Add a new commodity to the commodity table. This routine handles
|
||||
* the cases where the commodity already exists in the database (does
|
||||
* nothing), or another entries has the same namespace and mnemonic
|
||||
* (updates the existing entry).
|
||||
*
|
||||
* @param table A pointer to the commodity table for the book.
|
||||
*
|
||||
* @param comm A pointer to the commodity to add.
|
||||
*
|
||||
* @return The added commodity. Null on error.
|
||||
*
|
||||
* @note The commodity pointer passed to this function should not be
|
||||
* used after its return, as it may have been destroyed. Use the
|
||||
* return value which is guaranteed to be valid. */
|
||||
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table * table,
|
||||
gnc_commodity * comm);
|
||||
|
||||
/** Remove a commodity from the commodity table. If the commodity to
|
||||
* remove doesn't exist, nothing happens.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the book.
|
||||
*
|
||||
* @param comm A pointer to the commodity to remove. */
|
||||
void gnc_commodity_table_remove(gnc_commodity_table * table,
|
||||
gnc_commodity * comm);
|
||||
|
||||
/** Add all the standard namespaces and currencies to the commodity
|
||||
* table. This routine creates the namespaces for the NYSE, NASDAQ,
|
||||
* etc. It also adds all of the ISO 4217 currencies to the commodity
|
||||
* table.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the book. */
|
||||
gboolean gnc_commodity_table_add_default_data(gnc_commodity_table *table);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
||||
/** @name Commodity Table Namespace functions */
|
||||
/** @{ */
|
||||
|
||||
/** Return a count of the number of namespaces in the commodity table.
|
||||
* This count includes both system and user defined namespaces.
|
||||
*
|
||||
* @return The number of namespaces. Zero if an invalid argument was
|
||||
* supplied or there was an error. */
|
||||
guint gnc_commodity_table_get_number_of_namespaces(gnc_commodity_table* tbl);
|
||||
|
||||
/** Test to see if the indicated namespace exits in the commodity table.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the current
|
||||
* book.
|
||||
*
|
||||
* @param namespace The new namespace to check.
|
||||
*
|
||||
* @return 1 if the namespace exists. 0 if it doesn't exist, or the
|
||||
* routine was passed a bad argument. */
|
||||
int gnc_commodity_table_has_namespace(const gnc_commodity_table * t,
|
||||
const char * namespace);
|
||||
|
||||
guint gnc_commodity_table_get_size(gnc_commodity_table* tbl);
|
||||
guint gnc_commodity_table_get_number_of_namespaces(gnc_commodity_table* tbl);
|
||||
|
||||
/* The next two functions return newly allocated lists which should
|
||||
* be freed with g_list_free. */
|
||||
/** Return a list of all namespaces in the commodity table. This
|
||||
* returns both system and user defined namespaces.
|
||||
*
|
||||
* @return A pointer to the list of names. NULL if an invalid
|
||||
* argument was supplied.
|
||||
*
|
||||
* @note It is the callers responsibility to free the list. */
|
||||
GList * gnc_commodity_table_get_namespaces(const gnc_commodity_table * t);
|
||||
|
||||
/** This function adds a new string to the list of commodity namespaces.
|
||||
* If the new namespace already exists, nothing happens.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the current
|
||||
* book.
|
||||
*
|
||||
* @param namespace The new namespace to be added.*/
|
||||
void gnc_commodity_table_add_namespace(gnc_commodity_table * table,
|
||||
const char * namespace);
|
||||
|
||||
/** This function deletes a string from the list of commodity namespaces.
|
||||
* If the namespace does not exist, nothing happens.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the current
|
||||
* book.
|
||||
*
|
||||
* @param namespace The namespace to be deleted.
|
||||
*
|
||||
* @note This routine will destroy any commodities that exist as part
|
||||
* of this namespace. Use it carefully. */
|
||||
void gnc_commodity_table_delete_namespace(gnc_commodity_table * t,
|
||||
const char * namespace);
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @name Commodity Table Accessor functions */
|
||||
/** @{ */
|
||||
|
||||
/** Returns the number of commodities in the commodity table.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the current
|
||||
* book.
|
||||
*
|
||||
* @return The number of commodities in the table. 0 if there are no
|
||||
* commodities, or the routine was passed a bad argument. */
|
||||
guint gnc_commodity_table_get_size(gnc_commodity_table* tbl);
|
||||
|
||||
/** Return a list of all commodities in the commodity table that are
|
||||
* in the given namespace.
|
||||
*
|
||||
* @param namespace A string indicating which commodities should be
|
||||
* returned. It is a required argument.
|
||||
*
|
||||
* @return A pointer to the list of commodities. NULL if an invalid
|
||||
* argument was supplied, or the namespace could not be found.
|
||||
*
|
||||
* @note It is the callers responsibility to free the list. */
|
||||
GList * gnc_commodity_table_get_commodities(const gnc_commodity_table * t,
|
||||
const char * namespace);
|
||||
|
||||
void gnc_commodity_table_add_namespace(gnc_commodity_table * table,
|
||||
const char * namespace);
|
||||
void gnc_commodity_table_delete_namespace(gnc_commodity_table * t,
|
||||
/** This function returns a list of commodities for which price quotes
|
||||
* should be retrieved. It will scan the entire commodity table (or
|
||||
* a subset) and check each commodity to see if the price_quote_flag
|
||||
* field has been set. All matching commodities are queued onto a
|
||||
* list, and the head of that list is returned.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the current
|
||||
* book.
|
||||
*
|
||||
* @param namespace Use the given namespace as a filter on the
|
||||
* commodities to be returned. If non-null, only commodities in the
|
||||
* specified namespace are checked. If null, all commodities are
|
||||
* checked.
|
||||
*
|
||||
* @return A pointer to a list of commodities. NULL if invalid
|
||||
* arguments were supplied or if there no commodities are flagged for
|
||||
* quote retrieval.
|
||||
*
|
||||
* @note It is the callers responsibility to free the list. */
|
||||
GList * gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table,
|
||||
const char * namespace);
|
||||
|
||||
void gnc_commodity_table_remove_non_iso (gnc_commodity_table *t);
|
||||
|
||||
/* gnc_commodity_table_foreach_commodity - call f once for each commodity in
|
||||
* table, until and unless f returns FALSE.
|
||||
*/
|
||||
gboolean gnc_commodity_table_foreach_commodity(gnc_commodity_table * table,
|
||||
/** Call a function once for each commodity in the commodity table.
|
||||
* This table walk returns whenever the end of the table is reached,
|
||||
* or the function returns FALSE.
|
||||
*
|
||||
* @param table A pointer to the commodity table for the current
|
||||
* book.
|
||||
*
|
||||
* @param f The function to call for each commodity.
|
||||
*
|
||||
* @param user_data A pointer that is passed into the function
|
||||
* unchanged by the table walk routine. */
|
||||
gboolean gnc_commodity_table_foreach_commodity(const gnc_commodity_table * table,
|
||||
gboolean (*f)(gnc_commodity *cm,
|
||||
gpointer user_data),
|
||||
gpointer user_data);
|
||||
/** @} */
|
||||
|
||||
gboolean gnc_commodity_table_add_default_data(gnc_commodity_table *table);
|
||||
|
||||
#endif
|
||||
#endif /* GNC_COMMODITY_H */
|
||||
/** @} */
|
||||
|
@ -919,22 +919,6 @@ Expenses) are given numeric codes in corresponding ``number ranges.''")
|
||||
'((<gnc:Account*> a))
|
||||
"Get the tax payer name source set on the account.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:account-get-price-src
|
||||
'(<gw:mchars> callee-owned const)
|
||||
"xaccAccountGetPriceSrc"
|
||||
'((<gnc:Account*> a))
|
||||
"Get the account's price source, if any.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:account-get-quote-tz
|
||||
'(<gw:mchars> callee-owned const)
|
||||
"xaccAccountGetQuoteTZ"
|
||||
'((<gnc:Account*> a))
|
||||
"Get the quote source's timezone, if any.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:account-get-children
|
||||
@ -2189,7 +2173,16 @@ of having a parent transaction with which one is working...")
|
||||
"gnc_commodity_table_get_commodities"
|
||||
'((<gnc:commodity-table*> table)
|
||||
((<gw:mchars> caller-owned const) namespace))
|
||||
"Return a list of all the namespaces in the table.")
|
||||
"Return a list of all the commodities in a given namespace in the table.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:commodity-table-get-quotable-commodities
|
||||
'(gw:glist-of <gnc:commodity*> caller-owned)
|
||||
"gnc_commodity_table_get_quotable_commodities"
|
||||
'((<gnc:commodity-table*> table)
|
||||
((<gw:mchars> caller-owned const) namespace))
|
||||
"Return a list of all the quotable commodities in a given namespace in the table.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
|
@ -19,15 +19,16 @@
|
||||
<widget>
|
||||
<class>GnomeDialog</class>
|
||||
<name>Commodity Selector Dialog</name>
|
||||
<visible>False</visible>
|
||||
<title>Select currency/security </title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>True</allow_shrink>
|
||||
<allow_grow>True</allow_grow>
|
||||
<modal>True</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>False</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
<auto_close>False</auto_close>
|
||||
<hide_on_close>False</hide_on_close>
|
||||
<hide_on_close>True</hide_on_close>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
@ -60,15 +61,10 @@
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button63</name>
|
||||
<name>ok_button</name>
|
||||
<sensitive>False</sensitive>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>gnc_ui_select_commodity_ok_cb</handler>
|
||||
<data>Commodity_Selector_Dialog</data>
|
||||
<last_modification_time>Tue, 08 Aug 2000 16:55:03 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
|
||||
</widget>
|
||||
|
||||
@ -90,13 +86,8 @@
|
||||
<class>GtkButton</class>
|
||||
<name>button65</name>
|
||||
<can_default>True</can_default>
|
||||
<has_default>True</has_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>gnc_ui_select_commodity_cancel_cb</handler>
|
||||
<data>Commodity_Selector_Dialog</data>
|
||||
<last_modification_time>Tue, 08 Aug 2000 16:56:01 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -240,6 +231,11 @@
|
||||
<child_name>GtkCombo:entry</child_name>
|
||||
<name>commodity_entry</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>gnc_ui_select_commodity_changed_cb</handler>
|
||||
<last_modification_time>Sun, 13 Apr 2003 23:10:41 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>False</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
@ -254,22 +250,23 @@
|
||||
<widget>
|
||||
<class>GnomeDialog</class>
|
||||
<name>Commodity Dialog</name>
|
||||
<title>New Security</title>
|
||||
<visible>False</visible>
|
||||
<title>New Commodity</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>True</allow_shrink>
|
||||
<modal>True</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>True</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
<auto_shrink>True</auto_shrink>
|
||||
<auto_close>False</auto_close>
|
||||
<hide_on_close>False</hide_on_close>
|
||||
<hide_on_close>True</hide_on_close>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<child_name>GnomeDialog:vbox</child_name>
|
||||
<name>dialog-vbox13</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>8</spacing>
|
||||
<spacing>3</spacing>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>True</expand>
|
||||
@ -295,7 +292,8 @@
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button66</name>
|
||||
<name>ok_button</name>
|
||||
<sensitive>False</sensitive>
|
||||
<can_default>True</can_default>
|
||||
<has_default>True</has_default>
|
||||
<can_focus>True</can_focus>
|
||||
@ -310,15 +308,10 @@
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button67</name>
|
||||
<name>cancel_button</name>
|
||||
<can_default>True</can_default>
|
||||
<has_default>True</has_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>gnc_ui_commodity_cancel_cb</handler>
|
||||
<data>Commodity_Dialog</data>
|
||||
<last_modification_time>Wed, 11 Apr 2001 09:03:18 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
</widget>
|
||||
|
||||
@ -338,10 +331,12 @@
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox63</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<class>GtkFrame</class>
|
||||
<name>commodity_info_frame</name>
|
||||
<border_width>3</border_width>
|
||||
<label>Commodity Information</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
@ -349,15 +344,14 @@
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox77</name>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>2</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
<class>GtkTable</class>
|
||||
<name>table1</name>
|
||||
<border_width>5</border_width>
|
||||
<rows>5</rows>
|
||||
<columns>2</columns>
|
||||
<homogeneous>False</homogeneous>
|
||||
<row_spacing>3</row_spacing>
|
||||
<column_spacing>3</column_spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
@ -370,9 +364,18 @@
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@ -387,15 +390,24 @@
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label812</name>
|
||||
<name>namespace_label</name>
|
||||
<label>Type:</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
@ -404,9 +416,18 @@
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@ -421,9 +442,18 @@
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>3</top_attach>
|
||||
<bottom_attach>4</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@ -438,23 +468,20 @@
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>4</top_attach>
|
||||
<bottom_attach>5</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox78</name>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>2</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkEntry</class>
|
||||
@ -462,14 +489,28 @@
|
||||
<tooltip>Enter the full name of the commodity. Example: US Dollars</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<has_focus>True</has_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>gnc_ui_commodity_changed_cb</handler>
|
||||
<last_modification_time>Wed, 16 Apr 2003 06:17:13 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@ -478,14 +519,28 @@
|
||||
<name>mnemonic_entry</name>
|
||||
<tooltip>Enter the ticker symbol or currency code for the commodity. Example: USD</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>gnc_ui_commodity_changed_cb</handler>
|
||||
<last_modification_time>Wed, 16 Apr 2003 06:17:20 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@ -499,9 +554,18 @@
|
||||
<use_arrows_always>False</use_arrows_always>
|
||||
<items></items>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
@ -510,6 +574,11 @@
|
||||
<name>namespace_entry</name>
|
||||
<tooltip>Enter the type of commodity. For stocks, this is often an exchange on which the stock is traded. You can choose an existing type from the list or enter a new type with the keyboard.</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>gnc_ui_commodity_changed_cb</handler>
|
||||
<last_modification_time>Wed, 16 Apr 2003 06:17:30 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
@ -527,9 +596,18 @@
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>3</top_attach>
|
||||
<bottom_attach>4</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
@ -539,9 +617,18 @@
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>4</top_attach>
|
||||
<bottom_attach>5</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
@ -587,6 +674,226 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>price_quote_frame</name>
|
||||
<border_width>3</border_width>
|
||||
<label>Quote Source Information</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox129</name>
|
||||
<border_width>5</border_width>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>3</spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>finance_quote_warning</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkArrow</class>
|
||||
<name>arrow1</name>
|
||||
<arrow_type>GTK_ARROW_RIGHT</arrow_type>
|
||||
<shadow_type>GTK_SHADOW_OUT</shadow_type>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label654</name>
|
||||
<sensitive>False</sensitive>
|
||||
<label>Warning: Finance::Quote not installed properly.</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkArrow</class>
|
||||
<name>arrow2</name>
|
||||
<arrow_type>GTK_ARROW_LEFT</arrow_type>
|
||||
<shadow_type>GTK_SHADOW_OUT</shadow_type>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>get_quote_check</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>gnc_ui_commodity_quote_cb</handler>
|
||||
<last_modification_time>Sun, 20 Apr 2003 03:35:34 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Get Online Quotes</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkTable</class>
|
||||
<name>table2</name>
|
||||
<rows>2</rows>
|
||||
<columns>2</columns>
|
||||
<homogeneous>False</homogeneous>
|
||||
<row_spacing>3</row_spacing>
|
||||
<column_spacing>3</column_spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>source_label</name>
|
||||
<label>The source for price quotes:</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>quote_tz_label</name>
|
||||
<label>Timezone for these quotes:</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>source_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>quote_tz_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
|
@ -94,15 +94,6 @@ struct _AccountWindow
|
||||
GtkWidget * transfer_account_frame;
|
||||
GtkWidget * transfer_tree;
|
||||
|
||||
/* These probably don't belong here anymore, but until we figure out
|
||||
what we want, we'll leave them alone. */
|
||||
GtkWidget * price_quote_frame;
|
||||
GtkWidget * get_quote_check;
|
||||
GtkWidget * source_label;
|
||||
GtkWidget * source_menu;
|
||||
GtkWidget * quote_tz_label;
|
||||
GtkWidget * quote_tz_menu;
|
||||
|
||||
GtkWidget * tax_related_button;
|
||||
GtkWidget * placeholder_button;
|
||||
|
||||
@ -206,39 +197,6 @@ gnc_account_to_ui(AccountWindow *aw)
|
||||
placeholder = xaccAccountGetPlaceholder (account);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->placeholder_button),
|
||||
placeholder);
|
||||
|
||||
if ((STOCK != aw->type) && (MUTUAL != aw->type) && (CURRENCY != aw->type))
|
||||
return;
|
||||
|
||||
{
|
||||
/* we'll let GetPriceSrc handle the account type checking... */
|
||||
const char* price_src = xaccAccountGetPriceSrc (account);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->get_quote_check),
|
||||
price_src != NULL);
|
||||
|
||||
if (price_src && aw->type != CURRENCY)
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (aw->source_menu),
|
||||
gnc_price_source_internal2enum (price_src));
|
||||
}
|
||||
|
||||
{
|
||||
const char* quote_tz = xaccAccountGetQuoteTZ (account);
|
||||
guint pos = 0;
|
||||
|
||||
if (quote_tz)
|
||||
{
|
||||
pos = gnc_find_timezone_menu_position(quote_tz);
|
||||
if(pos == 0)
|
||||
{
|
||||
PWARN("Unknown price quote timezone (%s), resetting to default.",
|
||||
quote_tz ? quote_tz : "(null)");
|
||||
xaccAccountSetQuoteTZ (account, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (aw->quote_tz_menu), pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -349,50 +307,6 @@ gnc_ui_to_account(AccountWindow *aw)
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetCode (account, string);
|
||||
|
||||
if ((STOCK == aw->type) || (MUTUAL == aw->type) || (CURRENCY == aw->type))
|
||||
{
|
||||
gboolean get_quote;
|
||||
|
||||
get_quote = gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (aw->get_quote_check));
|
||||
|
||||
if (!get_quote)
|
||||
{
|
||||
if (xaccAccountGetPriceSrc (account))
|
||||
xaccAccountSetPriceSrc (account, NULL);
|
||||
}
|
||||
else if (CURRENCY == aw->type)
|
||||
{
|
||||
gint code;
|
||||
|
||||
old_string = xaccAccountGetPriceSrc (account);
|
||||
if (safe_strcmp ("CURRENCY", old_string) != 0)
|
||||
xaccAccountSetPriceSrc (account, "CURRENCY");
|
||||
|
||||
code = gnc_option_menu_get_active (aw->quote_tz_menu);
|
||||
string = gnc_timezone_menu_position_to_string(code);
|
||||
old_string = xaccAccountGetQuoteTZ (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetQuoteTZ (account, string);
|
||||
}
|
||||
else if ((STOCK == aw->type) || (MUTUAL == aw->type))
|
||||
{
|
||||
gint code;
|
||||
|
||||
code = gnc_option_menu_get_active (aw->source_menu);
|
||||
string = gnc_price_source_enum2internal (code);
|
||||
old_string = xaccAccountGetPriceSrc (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetPriceSrc (account, string);
|
||||
|
||||
code = gnc_option_menu_get_active (aw->quote_tz_menu);
|
||||
string = gnc_timezone_menu_position_to_string(code);
|
||||
old_string = xaccAccountGetQuoteTZ (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetQuoteTZ (account, string);
|
||||
}
|
||||
}
|
||||
|
||||
string = gtk_editable_get_chars (GTK_EDITABLE(aw->notes_text), 0, -1);
|
||||
old_string = xaccAccountGetNotes (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
@ -1156,7 +1070,6 @@ gnc_type_list_select_cb(GtkCList * type_list, gint row, gint column,
|
||||
GdkEventButton * event, gpointer data)
|
||||
{
|
||||
AccountWindow * aw = data;
|
||||
gboolean get_quote;
|
||||
gboolean sensitive;
|
||||
|
||||
if (aw == NULL)
|
||||
@ -1172,23 +1085,6 @@ gnc_type_list_select_cb(GtkCList * type_list, gint row, gint column,
|
||||
|
||||
last_used_account_type = aw->type;
|
||||
|
||||
get_quote = gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (aw->get_quote_check));
|
||||
|
||||
sensitive = (aw->type == STOCK ||
|
||||
aw->type == MUTUAL ||
|
||||
aw->type == CURRENCY);
|
||||
|
||||
gtk_widget_set_sensitive(aw->get_quote_check, sensitive);
|
||||
gtk_widget_set_sensitive(aw->quote_tz_menu, sensitive && get_quote);
|
||||
gtk_widget_set_sensitive(aw->quote_tz_label, sensitive && get_quote);
|
||||
|
||||
sensitive = (aw->type == STOCK ||
|
||||
aw->type == MUTUAL);
|
||||
|
||||
gtk_widget_set_sensitive(aw->source_menu, sensitive && get_quote);
|
||||
gtk_widget_set_sensitive(aw->source_label, sensitive && get_quote);
|
||||
|
||||
sensitive = (aw->type != EQUITY &&
|
||||
aw->type != CURRENCY &&
|
||||
aw->type != STOCK &&
|
||||
@ -1211,12 +1107,6 @@ gnc_type_list_unselect_cb(GtkCList * type_list, gint row, gint column,
|
||||
AccountWindow * aw = data;
|
||||
|
||||
aw->type = BAD_TYPE;
|
||||
|
||||
gtk_widget_set_sensitive(aw->get_quote_check, FALSE);
|
||||
gtk_widget_set_sensitive(aw->source_label, FALSE);
|
||||
gtk_widget_set_sensitive(aw->source_menu, FALSE);
|
||||
gtk_widget_set_sensitive(aw->quote_tz_label, FALSE);
|
||||
gtk_widget_set_sensitive(aw->quote_tz_menu, FALSE);
|
||||
}
|
||||
|
||||
|
||||
@ -1442,29 +1332,6 @@ opening_equity_cb (GtkWidget *w, gpointer data)
|
||||
gtk_widget_set_sensitive (aw->transfer_account_frame, !use_equity);
|
||||
}
|
||||
|
||||
static void
|
||||
get_quote_check_cb (GtkWidget *w, gpointer data)
|
||||
{
|
||||
AccountWindow *aw = data;
|
||||
gboolean get_quote;
|
||||
gboolean sensitive;
|
||||
|
||||
get_quote = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
|
||||
|
||||
sensitive = (aw->type == STOCK ||
|
||||
aw->type == MUTUAL ||
|
||||
aw->type == CURRENCY);
|
||||
|
||||
gtk_widget_set_sensitive(aw->quote_tz_label, sensitive && get_quote);
|
||||
gtk_widget_set_sensitive(aw->quote_tz_menu, sensitive && get_quote);
|
||||
|
||||
sensitive = (aw->type == STOCK ||
|
||||
aw->type == MUTUAL);
|
||||
|
||||
gtk_widget_set_sensitive(aw->source_label, sensitive && get_quote);
|
||||
gtk_widget_set_sensitive(aw->source_menu, sensitive && get_quote);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_account_window_create *
|
||||
* creates a window to create a new account. *
|
||||
@ -1530,27 +1397,6 @@ gnc_account_window_create(AccountWindow *aw)
|
||||
aw->account_scu = glade_xml_get_widget (xml, "account_scu");
|
||||
gnc_option_menu_init(aw->account_scu);
|
||||
|
||||
if (gnc_price_source_have_fq()) {
|
||||
gtk_widget_destroy(glade_xml_get_widget (xml, "finance_quote_warning"));
|
||||
} else {
|
||||
gtk_widget_set_sensitive(glade_xml_get_widget (xml, "price_quote_frame"),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
aw->get_quote_check = glade_xml_get_widget (xml, "get_quote_check");
|
||||
gtk_signal_connect (GTK_OBJECT (aw->get_quote_check), "toggled",
|
||||
GTK_SIGNAL_FUNC (get_quote_check_cb), aw);
|
||||
|
||||
aw->source_label = glade_xml_get_widget (xml, "source_label");
|
||||
box = glade_xml_get_widget (xml, "source_box");
|
||||
aw->source_menu = gnc_ui_source_menu_create(aw_get_account (aw));
|
||||
gtk_box_pack_start(GTK_BOX(box), aw->source_menu, TRUE, TRUE, 0);
|
||||
|
||||
aw->quote_tz_label = glade_xml_get_widget (xml, "quote_tz_label");
|
||||
box = glade_xml_get_widget (xml, "quote_tz_box");
|
||||
aw->quote_tz_menu = gnc_ui_quote_tz_menu_create(aw_get_account (aw));
|
||||
gtk_box_pack_start(GTK_BOX(box), aw->quote_tz_menu, TRUE, TRUE, 0);
|
||||
|
||||
box = glade_xml_get_widget (xml, "parent_scroll");
|
||||
|
||||
aw->top_level_account = xaccMallocAccount(gnc_get_current_book ());
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,13 @@
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
********************************************************************/
|
||||
|
||||
/** @addtogroup UI
|
||||
@{ */
|
||||
/** @file dialog-commodity.h
|
||||
@brief "select" and "new" commodity windows
|
||||
@author Copyright (C) 2000 Bill Gribble <grib@billgribble.com>
|
||||
*/
|
||||
|
||||
#ifndef GNC_DIALOG_COMMODITY_H
|
||||
#define GNC_DIALOG_COMMODITY_H
|
||||
|
||||
@ -29,63 +36,208 @@
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-engine.h"
|
||||
|
||||
typedef struct select_commodity_window SelectCommodityWindow;
|
||||
typedef struct commodity_window CommodityWindow;
|
||||
|
||||
typedef void (* gnc_commodity_callback)(const gnc_commodity *, void * data);
|
||||
typedef void (* gnc_commodity_help_callback)(void);
|
||||
|
||||
/** This function is used to set the action routine for the help
|
||||
* button in the commodity dialog windows. If the action routine is
|
||||
* unset, the help button will not be visible to the user.
|
||||
*
|
||||
* @param cb The function to be called when the user clicks the help
|
||||
* button. */
|
||||
void gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb);
|
||||
|
||||
void gnc_ui_select_commodity_destroy(SelectCommodityWindow * w);
|
||||
|
||||
void gnc_ui_commodity_destroy(CommodityWindow * w);
|
||||
|
||||
/*Offer the user to select a commodity matching exchange_code,
|
||||
fullname and mnemonic. If the user decides to create a new one, those
|
||||
values are used as default. If fullname is NULL, the user won't be
|
||||
told he has to match anything in perticular.*/
|
||||
/** @name Commodity Selection */
|
||||
/** @{ */
|
||||
|
||||
/** Ask the user to select a commodity from the existing set of
|
||||
* commodities. Arguments to this function determine the message
|
||||
* placed at the top of the dialog but force no restriction on the
|
||||
* commodities that may be chosen. The user will also have the
|
||||
* option of creating a new commodity from this dialog box.. If the
|
||||
* user decides to create a new one, those provided values are used
|
||||
* as default values for the new commodity.
|
||||
*
|
||||
* @param orig_sel A pointer to a commodity that should initially be
|
||||
* selected in the dialog box.
|
||||
*
|
||||
* @param parent The parent window of the new dialog.
|
||||
*
|
||||
* @param user_message A string that will be installed in the top of
|
||||
* the dialog box as an instruction to the user. If NULL, a generic
|
||||
* instruction will be used.
|
||||
*
|
||||
* @param exchange_code If present, a note will be added to the user
|
||||
* instruction providing this exchange specific code, and this will
|
||||
* be the default exchange code for any newly created commodities.
|
||||
*
|
||||
* @param fullname If present, a note will be added to the user
|
||||
* instruction providing this commodity's full name, and this will be
|
||||
* the default fullname for any newly created commodities.
|
||||
*
|
||||
* @param mnemonic If present, a note will be added to the user
|
||||
* instruction providing this commodity's mnemonic, and this will be
|
||||
* the default mnemonic for any newly created commodities.
|
||||
*
|
||||
* @return The commodity selected. May or may not be a newly created
|
||||
* commodity.
|
||||
*/
|
||||
gnc_commodity *
|
||||
gnc_ui_select_commodity_modal_full(gnc_commodity * orig_sel,
|
||||
GtkWidget * parent,
|
||||
char * user_message,
|
||||
char * exchange_code,
|
||||
char * fullname,
|
||||
char * mnemonic,
|
||||
int fraction);
|
||||
const char * user_message,
|
||||
const char * exchange_code,
|
||||
const char * fullname,
|
||||
const char * mnemonic);
|
||||
|
||||
|
||||
/** Ask the user to select a commodity from the existing set of
|
||||
* commodities. The user will also have the
|
||||
* option of creating a new commodity from this dialog box.. If the
|
||||
* user decides to create a new one, those provided values are used
|
||||
* as default values for the new commodity.
|
||||
*
|
||||
* @param orig_sel A pointer to a commodity that should initially be
|
||||
* selected in the dialog box.
|
||||
*
|
||||
* @return The commodity selected. May or may not be a newly created
|
||||
* commodity.
|
||||
*/
|
||||
gnc_commodity *
|
||||
gnc_ui_select_commodity_modal(gnc_commodity * orig_sel,
|
||||
GtkWidget * parent);
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @name Commodity Creation or Modification */
|
||||
/** @{ */
|
||||
|
||||
/** Ask the user to provide the information necessary to create a new
|
||||
* commodity.
|
||||
*
|
||||
* @param namespace If present, this will be the default namespace
|
||||
* for the new commodity. This value will be ignored if it is the
|
||||
* namespace for ISO 4217 currencies.
|
||||
*
|
||||
* @param parent The parent window of the new dialog.
|
||||
*
|
||||
* @param user_message A string that will be installed in the top of
|
||||
* the dialog box as an instruction to the user. If NULL, a generic
|
||||
* instruction will be used.
|
||||
*
|
||||
* @param exchange_code If present, this will be the default exchange
|
||||
* code for the new commodity.
|
||||
*
|
||||
* @param fullname If present, this will be the default fullname for
|
||||
* the new commodity.
|
||||
*
|
||||
* @param mnemonic If present, this will be the default mnemonic for
|
||||
* the new commodity.
|
||||
*
|
||||
* @param fraction If present, this will be the default fraction for
|
||||
* the new commodity. If absent, a default of 1000 will be used.
|
||||
*
|
||||
* @return The newly created commodity, or NULL if the user cancelled.
|
||||
*/
|
||||
gnc_commodity *
|
||||
gnc_ui_new_commodity_modal_full(const char * default_namespace,
|
||||
gnc_ui_new_commodity_modal_full(const char * namespace,
|
||||
GtkWidget * parent,
|
||||
char * exchange_code,
|
||||
char * fullname,
|
||||
char * mnemonic,
|
||||
const char * exchange_code,
|
||||
const char * fullname,
|
||||
const char * mnemonic,
|
||||
int fraction);
|
||||
|
||||
/** Ask the user to provide the information necessary to create a new
|
||||
* commodity.
|
||||
*
|
||||
* @param namespace If present, this will be the default namespace
|
||||
* for the new commodity. This value will be ignored if it is the
|
||||
* namespace for ISO 4217 currencies.
|
||||
*
|
||||
* @param parent The parent window of the new dialog.
|
||||
*
|
||||
* @return The newly created commodity, or NULL if the user cancelled.
|
||||
*/
|
||||
gnc_commodity *
|
||||
gnc_ui_new_commodity_modal(const char * default_namespace,
|
||||
GtkWidget * parent
|
||||
);
|
||||
|
||||
/** Allow the user to edit the information about a commodity. For
|
||||
* currencies, only the price quote information may be changed. For
|
||||
* any other commodity, all aspects of the commodity information may
|
||||
* be changed except that the namespace may not be changed to
|
||||
* indicate a currency. The new information overwrites any old
|
||||
* information, so this routine may not be used to create new
|
||||
* commodities.
|
||||
*
|
||||
* @param commodity The commodity to edit.
|
||||
*
|
||||
* @param parent The parent window of the new dialog.
|
||||
*
|
||||
* @return The newly created commodity, or NULL if the user cancelled.
|
||||
*/
|
||||
gboolean
|
||||
gnc_ui_edit_commodity_modal(gnc_commodity *commodity,
|
||||
GtkWidget * parent);
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @name Auxiliary Dialog Functions */
|
||||
/** @{ */
|
||||
|
||||
/** Given a combo box, fill in the known commodity namespaces and then
|
||||
* select one.
|
||||
*
|
||||
* @param combobox The combo box to populate with information.
|
||||
*
|
||||
* @param sel The namespace that should be initially selected when
|
||||
* the combo box appears.
|
||||
*
|
||||
* @param include_iso Set to TRUE if the combo box should inlude the
|
||||
* ISO4217 namespace for currencies. FALSE if the currency namespace
|
||||
* should not be included. This flag has precedence over the
|
||||
* following flag.
|
||||
*
|
||||
* @param include_all Set to TRUE if the combo box should include all
|
||||
* known namespaces, both application and user defined. FALSE if
|
||||
* only the default application namespaces should be included.
|
||||
*
|
||||
* @return The currently selected namespace.
|
||||
*
|
||||
* @note The returned string must be freed by the caller.
|
||||
*/
|
||||
char * gnc_ui_update_namespace_picker(GtkWidget * combobox,
|
||||
const char * sel,
|
||||
gboolean include_iso,
|
||||
gboolean include_all);
|
||||
|
||||
/** Given a combo box, return the currently selected namespaces.
|
||||
*
|
||||
* @param combobox The combo box of namespaces.
|
||||
*
|
||||
* @return The currently selected namespace.
|
||||
*
|
||||
* @note This string is owned by the engine and must not be freed by
|
||||
* the caller.
|
||||
*/
|
||||
const char * gnc_ui_namespace_picker_ns (GtkWidget *combobox);
|
||||
|
||||
/** Given a combo box, fill in all the known commodities for the
|
||||
* specified namespace, and then select one.
|
||||
*
|
||||
* @param combobox The combo box to populate with information.
|
||||
*
|
||||
* @param namespace All commodities with this namespace will be added
|
||||
* to the combo box.
|
||||
*
|
||||
* @param sel The commodity that should be initially selected when
|
||||
* the combo box appears.
|
||||
*/
|
||||
void gnc_ui_update_commodity_picker(GtkWidget * combobox,
|
||||
const char * namespace,
|
||||
const char * sel);
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
/** @} */
|
||||
|
@ -51,7 +51,7 @@ static short module = MOD_GUI;
|
||||
* Returns: the menu *
|
||||
\*******************************************************************/
|
||||
GtkWidget *
|
||||
gnc_ui_source_menu_create(Account *account)
|
||||
gnc_ui_source_menu_create(void)
|
||||
{
|
||||
gint i;
|
||||
GtkMenu *menu;
|
||||
@ -118,7 +118,7 @@ gnc_timezone_menu_position_to_string(guint pos)
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gnc_ui_quote_tz_menu_create(Account *account)
|
||||
gnc_ui_quote_tz_menu_create(void)
|
||||
{
|
||||
GtkMenu *menu;
|
||||
GtkWidget *item;
|
||||
|
@ -54,14 +54,14 @@ struct _GNCOptionInfo
|
||||
* Args: account - account to use to set default choice *
|
||||
* Returns: the menu *
|
||||
\*******************************************************************/
|
||||
GtkWidget * gnc_ui_source_menu_create (Account *account);
|
||||
GtkWidget * gnc_ui_source_menu_create (void);
|
||||
|
||||
/********************************************************************\
|
||||
* price quote timezone handling
|
||||
*/
|
||||
guint gnc_find_timezone_menu_position(const gchar *timezone);
|
||||
gchar * gnc_timezone_menu_position_to_string(guint pos);
|
||||
GtkWidget * gnc_ui_quote_tz_menu_create (Account *account);
|
||||
GtkWidget * gnc_ui_quote_tz_menu_create (void);
|
||||
|
||||
GtkWidget * gnc_build_option_menu (GNCOptionInfo *option_info,
|
||||
gint num_options);
|
||||
|
@ -408,162 +408,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>price_quote_frame</name>
|
||||
<border_width>3</border_width>
|
||||
<label>Price Quote Source</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox129</name>
|
||||
<border_width>3</border_width>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>3</spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>get_quote_check</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Get Online Quotes</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox103</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>2</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox116</name>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>source_label</name>
|
||||
<label>The source for price quotes:</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>quote_tz_label</name>
|
||||
<label>Timezone for these quotes:</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox117</name>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>source_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>quote_tz_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>finance_quote_warning</name>
|
||||
<sensitive>False</sensitive>
|
||||
<label>Warning: Finance::Quote not installed properly.</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>frame32</name>
|
||||
|
@ -117,11 +117,10 @@ gnc_commodity * gnc_import_select_commodity(char * exchange_code,
|
||||
{
|
||||
retval=gnc_ui_select_commodity_modal_full(NULL,
|
||||
NULL,
|
||||
_("Please select a commodity to match the following exchange code.\nPlease note that the exchange code of the commodity you select will be overwritten.\n"),
|
||||
_("Please select a commodity to match the following exchange specific code.\nPlease note that the exchange code of the commodity you select will be overwritten.\n"),
|
||||
exchange_code,
|
||||
default_fullname,
|
||||
default_mnemonic,
|
||||
0);
|
||||
default_mnemonic);
|
||||
|
||||
}
|
||||
if (retval != NULL&&
|
||||
|
@ -353,38 +353,9 @@
|
||||
|
||||
(define (gnc:book-add-quotes book)
|
||||
|
||||
(define (find-quotables group)
|
||||
;; Return a list of accounts for whose commodities we should get
|
||||
;; quotes.
|
||||
(define (quotable-currency-account? a)
|
||||
(let ((commodity (gnc:account-get-commodity a)))
|
||||
(equal? (gnc:commodity-get-namespace commodity) "ISO4217")))
|
||||
|
||||
(define (quotable-account? a)
|
||||
(let ((type (gw:enum-<gnc:AccountType>-val->sym (gnc:account-get-type a)
|
||||
#f))
|
||||
(src (gnc:account-get-price-src a))
|
||||
(balance (not (gnc:numeric-zero-p (gnc:account-get-balance a)))))
|
||||
|
||||
(if (not type) (set! type '()))
|
||||
(if (symbol? type) (set! type (list type)))
|
||||
(if (and src
|
||||
(or (memq 'stock type)
|
||||
(memq 'mutual-fund type)
|
||||
(and (memq 'currency type)
|
||||
(quotable-currency-account? a))))
|
||||
a
|
||||
#f)))
|
||||
|
||||
(let ((quotables (filter quotable-account? (gnc:group-get-subaccounts group))))
|
||||
(if (null? quotables)
|
||||
#f
|
||||
quotables))
|
||||
)
|
||||
|
||||
(define (accounts->fq-call-data account-list)
|
||||
;; Take a list of accounts that should be "quotable" -- i.e. they
|
||||
;; have a price-source, and are of the right type, and return a
|
||||
(define (book->commodity->fq-call-data book)
|
||||
;; Call helper that walks all of the defined commodities to see if
|
||||
;; any are marked for quote retrieval. This function returns a
|
||||
;; list of info needed for the relevant Finance::Quote calls, and
|
||||
;; a list of the corresponding commodities. Also perform a bit of
|
||||
;; optimization, merging calls for symbols to the same
|
||||
@ -400,34 +371,25 @@
|
||||
;; (commodity-4 currency-4 tz-4) ...)
|
||||
;; ...)
|
||||
|
||||
(define (account->fq-cmd account)
|
||||
;; Returns (cons fq-method-sym
|
||||
;; (list commodity currency assumed-timezone-str))
|
||||
(let* ((commodity (gnc:account-get-commodity account))
|
||||
(currency (gnc:default-currency))
|
||||
(src (and account (gnc:account-get-price-src account)))
|
||||
(tz (gnc:account-get-quote-tz account))
|
||||
(fq-method-sym (and src (gnc:price-source-internal2fq src)))
|
||||
(mnemonic (and commodity (gnc:commodity-get-mnemonic commodity))))
|
||||
(and
|
||||
commodity
|
||||
currency
|
||||
fq-method-sym
|
||||
mnemonic
|
||||
(list fq-method-sym commodity currency tz))))
|
||||
|
||||
(let* ((big-list (delete #f (map account->fq-cmd account-list)))
|
||||
(cmd-list #f)
|
||||
(currency-cmd-list (call-with-values
|
||||
(let* ((ct (gnc:book-get-commodity-table book))
|
||||
(big-list (gnc:commodity-table-get-quotable-commodities-info ct ""))
|
||||
(commodity-list #f)
|
||||
(currency-list (filter
|
||||
(lambda (a) (not (equal? (cadr a) (caddr a))))
|
||||
(call-with-values
|
||||
(lambda () (partition!
|
||||
(lambda (cmd)
|
||||
(not (equal? (car cmd) "currency")))
|
||||
(not (string=? (car cmd) "currency")))
|
||||
big-list))
|
||||
(lambda (a b) (set! cmd-list a) b)))
|
||||
(cmd-hash (make-hash-table 31)))
|
||||
(lambda (a b) (set! commodity-list a) b))))
|
||||
(quote-hash (make-hash-table 31)))
|
||||
|
||||
(if (null? big-list)
|
||||
#f
|
||||
(begin
|
||||
|
||||
;; Now collect symbols going to the same backend.
|
||||
(item-list->hash! cmd-list cmd-hash car cdr hash-ref hash-set! #t)
|
||||
(item-list->hash! commodity-list quote-hash car cdr hash-ref hash-set! #t)
|
||||
|
||||
;; Now translate to just what finance-quote-helper expects.
|
||||
(append
|
||||
@ -436,15 +398,15 @@
|
||||
(cons (cons key value)
|
||||
prior-result))
|
||||
'()
|
||||
cmd-hash)
|
||||
quote-hash)
|
||||
(map (lambda (cmd) (cons (car cmd) (list (cdr cmd))))
|
||||
currency-cmd-list))))
|
||||
currency-list))))))
|
||||
|
||||
(define (fq-call-data->fq-calls fq-call-data)
|
||||
;; take an output element from accounts->fq-call-data and return a
|
||||
;; list where the gnc_commodities have been converted to their
|
||||
;; fq-suitable symbol strings. i.e. turn the former into the
|
||||
;; latter:
|
||||
;; take an output element from book->commodity->fq-call-data and
|
||||
;; return a list where the gnc_commodities have been converted to
|
||||
;; their fq-suitable symbol strings. i.e. turn the former into
|
||||
;; the latter:
|
||||
;;
|
||||
;; ("yahoo" (commodity-1 currency-1 tz-1)
|
||||
;; (commodity-2 currency-2 tz-2) ...)
|
||||
@ -613,8 +575,7 @@
|
||||
;; now, they'll result in funny formatting.
|
||||
|
||||
(let* ((group (gnc:book-get-group book))
|
||||
(quotables (and group (find-quotables group)))
|
||||
(fq-call-data (and quotables (accounts->fq-call-data quotables)))
|
||||
(fq-call-data (book->commodity->fq-call-data book))
|
||||
(fq-calls (and fq-call-data
|
||||
(apply append
|
||||
(map fq-call-data->fq-calls fq-call-data))))
|
||||
@ -642,11 +603,11 @@
|
||||
(keep-going? #t))
|
||||
|
||||
(cond
|
||||
((eq? quotables #f)
|
||||
((eq? fq-call-data #f)
|
||||
(set! keep-going? #f)
|
||||
(if (gnc:ui-is-running?)
|
||||
(gnc:error-dialog (_ "No accounts marked for quote retrieval."))
|
||||
(gnc:warn (_ "No accounts marked for quote retrieval."))))
|
||||
(gnc:error-dialog (_ "No commodities marked for quote retrieval."))
|
||||
(gnc:warn (_ "No commodities marked for quote retrieval."))))
|
||||
((eq? fq-results #f)
|
||||
(set! keep-going? #f)
|
||||
(if (gnc:ui-is-running?)
|
||||
|
Loading…
Reference in New Issue
Block a user