diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-09-28 06:00:33 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-09-28 06:02:26 +0800 |
commit | 807184393ae4d9bd271797d74775939dd353dbd3 (patch) | |
tree | 862be78019372c7e755ae36f83c98cb3383bb657 /mail/e-mail-folder-utils.c | |
parent | f80a74004ed303b66f4b279e3f772493b4e80ced (diff) | |
download | gsoc2013-evolution-807184393ae4d9bd271797d74775939dd353dbd3.tar.gz gsoc2013-evolution-807184393ae4d9bd271797d74775939dd353dbd3.tar.zst gsoc2013-evolution-807184393ae4d9bd271797d74775939dd353dbd3.zip |
Bug 659726 - Search Folders contain ambiguous reference to accounts
This introduces a new function called e_mail_folder_uri_to_markup(),
which may prove useful in other contexts.
Diffstat (limited to 'mail/e-mail-folder-utils.c')
-rw-r--r-- | mail/e-mail-folder-utils.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mail/e-mail-folder-utils.c b/mail/e-mail-folder-utils.c index 7c84957f6a..77a9708e5f 100644 --- a/mail/e-mail-folder-utils.c +++ b/mail/e-mail-folder-utils.c @@ -1630,3 +1630,51 @@ e_mail_folder_uri_from_folder (CamelFolder *folder) return e_mail_folder_uri_build (store, folder_name); } + +/** + * e_mail_folder_uri_to_markup: + * @session: a #CamelSession + * @folder_uri: a folder URI + * @error: return location for a #GError, or %NULL + * + * Converts @folder_uri to a markup string suitable for displaying to users. + * The string consists of the #CamelStore display name (in bold), followed + * by the folder path. If the URI is malformed or no corresponding store + * exists, the function sets @error and returns %NULL. Free the returned + * string with g_free(). + * + * Returns: a newly-allocated markup string, or %NULL + **/ +gchar * +e_mail_folder_uri_to_markup (CamelSession *session, + const gchar *folder_uri, + GError **error) +{ + CamelStore *store = NULL; + const gchar *display_name; + gchar *folder_name = NULL; + gchar *markup; + gboolean success; + + g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL); + g_return_val_if_fail (folder_uri != NULL, NULL); + + success = e_mail_folder_uri_parse ( + session, folder_uri, &store, &folder_name, error); + + if (!success) + return NULL; + + g_return_val_if_fail (CAMEL_IS_STORE (store), NULL); + g_return_val_if_fail (folder_name != NULL, NULL); + + display_name = camel_service_get_display_name (CAMEL_SERVICE (store)); + + markup = g_markup_printf_escaped ( + "<b>%s</b> : %s", display_name, folder_name); + + g_object_unref (store); + g_free (folder_name); + + return markup; +} |