示例#1
0
static gnc_commodity *
gnc_commodity_find_currency (QofBook *book, xmlNodePtr tree)
{
    gnc_commodity_table * table;
    gnc_commodity *currency = NULL;
    gchar *exchange = NULL, *mnemonic = NULL;
    xmlNodePtr node;

    for (node = tree->xmlChildrenNode; node; node = node->next)
    {
        if (g_strcmp0((char*) node->name, cmdty_namespace) == 0)
            exchange = (gchar*) xmlNodeGetContent (node->xmlChildrenNode);
        if (g_strcmp0((char*) node->name, cmdty_id) == 0)
            mnemonic = (gchar*) xmlNodeGetContent (node->xmlChildrenNode);
    }

    if (exchange
            && gnc_commodity_namespace_is_iso(exchange)
            && mnemonic)
    {
        table = gnc_commodity_table_get_table(book);
        currency = gnc_commodity_table_lookup(table, exchange, mnemonic);
    }

    if (exchange)
        xmlFree(exchange);
    if (mnemonic)
        xmlFree(mnemonic);

    return currency;
}
static gboolean
gnc_commodities_dialog_filter_ns_func (gnc_commodity_namespace *comm_namespace,
                                       gpointer data)
{
    CommoditiesDialog *cd = data;
    const gchar *name;
    GList *list;

    /* Never show the template list */
    name = gnc_commodity_namespace_get_name (comm_namespace);
    if (g_strcmp0 (name, "template") == 0)
        return FALSE;

    /* Check whether or not to show commodities */
    if (!cd->show_currencies && gnc_commodity_namespace_is_iso(name))
        return FALSE;

    /* Show any other namespace that has commodities */
    list = gnc_commodity_namespace_get_commodity_list(comm_namespace);
    return (list != NULL);
}