diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2009-06-08 03:53:50 +0800 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2009-06-08 03:53:50 +0800 |
commit | 03f13ebc2457e06ea2c90153777c57a4921876a9 (patch) | |
tree | aa00eb9b370c56d427de80e03ee0d7e56f5af0a2 /src | |
parent | fe0b029e662224a5218f09eeabb0a49739620740 (diff) | |
download | gsoc2013-empathy-03f13ebc2457e06ea2c90153777c57a4921876a9.tar gsoc2013-empathy-03f13ebc2457e06ea2c90153777c57a4921876a9.tar.gz gsoc2013-empathy-03f13ebc2457e06ea2c90153777c57a4921876a9.tar.bz2 gsoc2013-empathy-03f13ebc2457e06ea2c90153777c57a4921876a9.tar.lz gsoc2013-empathy-03f13ebc2457e06ea2c90153777c57a4921876a9.tar.xz gsoc2013-empathy-03f13ebc2457e06ea2c90153777c57a4921876a9.tar.zst gsoc2013-empathy-03f13ebc2457e06ea2c90153777c57a4921876a9.zip |
Extract markup_printf-append-free to a function
The repeated g_markup_printf_escaped; g_string_append; g_free offended
me. I think this makes the function easier to read.
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-chat-window.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index bb168b6bb..ab3de4092 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -382,6 +382,23 @@ chat_window_update (EmpathyChatWindow *window) } static void +append_markup_printf (GString *string, + const char *format, + ...) +{ + gchar *tmp; + va_list args; + + va_start (args, format); + + tmp = g_markup_vprintf_escaped (format, args); + g_string_append (string, tmp); + g_free (tmp); + + va_end (args); +} + +static void chat_window_update_chat_tab (EmpathyChat *chat) { EmpathyChatWindow *window; @@ -432,36 +449,30 @@ chat_window_update_chat_tab (EmpathyChat *chat) tooltip = g_string_new (NULL); if (remote_contact) { - markup = g_markup_printf_escaped ("<b>%s</b><small> (%s)</small>", - empathy_contact_get_id (remote_contact), - mc_account_get_display_name (account)); - g_string_append (tooltip, markup); - g_free (markup); + append_markup_printf (tooltip, + "<b>%s</b><small> (%s)</small>", + empathy_contact_get_id (remote_contact), + mc_account_get_display_name (account)); status = empathy_contact_get_status (remote_contact); if (status) { - markup = g_markup_printf_escaped ("\n%s", status); - g_string_append (tooltip, markup); - g_free (markup); + append_markup_printf (tooltip, "\n%s", status); } } else { - markup = g_markup_printf_escaped ("<b>%s</b><small> (%s)</small>", name, - mc_account_get_display_name (account)); - g_string_append (tooltip, markup); - g_free (markup); + append_markup_printf (tooltip, + "<b>%s</b><small> (%s)</small>", name, + mc_account_get_display_name (account)); } if (subject) { - markup = g_markup_printf_escaped ("\n<b>%s</b> %s", _("Topic:"), subject); - g_string_append (tooltip, markup); - g_free (markup); + append_markup_printf (tooltip, "\n<b>%s</b> %s", + _("Topic:"), subject); } + if (g_list_find (priv->chats_composing, chat)) { - markup = g_markup_printf_escaped ("\n%s", _("Typing a message.")); - g_string_append (tooltip, markup); - g_free (markup); + append_markup_printf (tooltip, "\n%s", _("Typing a message.")); } markup = g_string_free (tooltip, FALSE); |