From ab49ff67c832b064136f47917ad9de4ceb74d45a Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Mon, 15 Dec 2008 13:37:56 +0000 Subject: [PATCH] Added varargs get_translation function and sort the code to use it pmo-trunk-r6842 --- src/modest-protocol.c | 24 ++++++++++++++++++++---- src/modest-protocol.h | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/modest-protocol.c b/src/modest-protocol.c index 03eaa8b..48c5f28 100644 --- a/src/modest-protocol.c +++ b/src/modest-protocol.c @@ -358,9 +358,26 @@ modest_protocol_get_translation (ModestProtocol *self, const gchar *id, ...) { + va_list args; + gchar *result; + + g_return_val_if_fail (MODEST_IS_PROTOCOL (self), NULL); + + va_start (args, id); + result = modest_protocol_va_get_translation (self, id, args); + va_end (args); + + return result; +} + +gchar * +modest_protocol_va_get_translation (ModestProtocol *self, + const gchar *id, + va_list args) +{ ModestProtocolPrivate *priv; ModestProtocolTranslation *translation; - va_list orig, dest; + va_list dest; gchar *result; g_return_val_if_fail (MODEST_IS_PROTOCOL (self), NULL); @@ -372,10 +389,9 @@ modest_protocol_get_translation (ModestProtocol *self, return NULL; g_return_val_if_fail (translation->translation_func != NULL, NULL); - va_start (orig, id); - G_VA_COPY (dest, orig); + G_VA_COPY (dest, args); result = translation->translation_func (translation->userdata, dest); - va_end (orig); + va_end (dest); return result; } diff --git a/src/modest-protocol.h b/src/modest-protocol.h index 6a113cf..b8899d3 100644 --- a/src/modest-protocol.h +++ b/src/modest-protocol.h @@ -182,6 +182,21 @@ modest_protocol_get_translation (ModestProtocol *protocol, const gchar *id, ...); +/** + * modest_protocol_va_get_translation: + * @protocol: a @ModestProtocol + * @id: the id for the translation set + * @args: a @va_list of the parameters for the translation + * + * applies the translation with parameters to obtain the full string expected. + * + * Returns: a newly allocated string + */ +gchar * +modest_protocol_va_get_translation (ModestProtocol *protocol, + const gchar *id, + va_list args); + G_END_DECLS #endif /* __MODEST_PROTOCOL_H__ */ -- 1.7.9.5