r23321 - gnucash/trunk/src/engine - Add a new user_symbol property to the Commodity class
Geert Janssens
gjanssens at code.gnucash.org
Thu Oct 24 08:27:38 EDT 2013
Author: gjanssens
Date: 2013-10-24 08:27:37 -0400 (Thu, 24 Oct 2013)
New Revision: 23321
Trac: http://svn.gnucash.org/trac/changeset/23321
Modified:
gnucash/trunk/src/engine/gnc-commodity.c
gnucash/trunk/src/engine/gnc-commodity.h
Log:
Add a new user_symbol property to the Commodity class
Author: Frédéric Perrin <frederic.perrin at resel.fr>
Modified: gnucash/trunk/src/engine/gnc-commodity.c
===================================================================
--- gnucash/trunk/src/engine/gnc-commodity.c 2013-10-24 12:27:26 UTC (rev 23320)
+++ gnucash/trunk/src/engine/gnc-commodity.c 2013-10-24 12:27:37 UTC (rev 23321)
@@ -1128,6 +1128,18 @@
}
/********************************************************************
+ * gnc_commodity_get_user_symbol
+ ********************************************************************/
+
+const char*
+gnc_commodity_get_user_symbol(const gnc_commodity *cm)
+{
+ const char *str;
+ if (!cm) return NULL;
+ return kvp_frame_get_string(cm->inst.kvp_data, "user_symbol");
+}
+
+/********************************************************************
* gnc_commodity_set_mnemonic
********************************************************************/
@@ -1362,6 +1374,25 @@
}
/********************************************************************
+ * gnc_commodity_set_user_symbol
+ ********************************************************************/
+
+void
+gnc_commodity_set_user_symbol(gnc_commodity * cm, const char * user_symbol)
+{
+ if (!cm) return;
+
+ ENTER ("(cm=%p, symbol=%s)", cm, user_symbol ? user_symbol : "(null)");
+
+ gnc_commodity_begin_edit(cm);
+ kvp_frame_set_string(cm->inst.kvp_data, "user_symbol", user_symbol);
+ mark_commodity_dirty(cm);
+ gnc_commodity_commit_edit(cm);
+
+ LEAVE(" ");
+}
+
+/********************************************************************
* gnc_commodity_increment_usage_count
********************************************************************/
Modified: gnucash/trunk/src/engine/gnc-commodity.h
===================================================================
--- gnucash/trunk/src/engine/gnc-commodity.h 2013-10-24 12:27:26 UTC (rev 23320)
+++ gnucash/trunk/src/engine/gnc-commodity.h 2013-10-24 12:27:37 UTC (rev 23321)
@@ -458,10 +458,20 @@
* caller.
*/
const char* gnc_commodity_get_quote_tz(const gnc_commodity *cm);
+
+/** Retrieve the user-defined symbol for the specified commodity. This
+ * will be a pointer to a nul terminated string like "£", "US$", etc.
+ *
+ * @param cm A pointer to a commodity data structure.
+ *
+ * @return A pointer to the user-defined symbol for this commodity.
+ * NULL means that the user didn't define any symbol, and that fallback to
+ * e.g. the mnemonic is in order. This string is owned by the engine and
+ * should not be freed by the caller.
+ */
+const char* gnc_commodity_get_user_symbol(const gnc_commodity *cm);
/** @} */
-
-
/** @name Commodity Accessor Routines - Set
@{
*/
@@ -581,9 +591,18 @@
* engine.
*/
void gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz);
+
+/** Set a user-defined symbol for the specified commodity. This should
+ * be a pointer to a nul terminated string like "£", "US$", etc.
+ *
+ * @param cm A pointer to a commodity data structure.
+ *
+ * @param tz A pointer to the symbol for this commodity. This string
+ * belongs to the caller and will be duplicated by the engine.
+ */
+void gnc_commodity_set_user_symbol(gnc_commodity *cm, const char *user_symbol);
/** @} */
-
/** @name Commodity Usage Count Adjustment Routines
@{
*/
More information about the gnucash-changes
mailing list