From 14ff443cfcc8419bd3368917b5e19512c4e37068 Mon Sep 17 00:00:00 2001 From: Artem Garmash Date: Sun, 7 Feb 2010 00:53:35 +0200 Subject: [PATCH] Resolve service icon when account manager is ready --- src/el-home-applet.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/el-home-applet.c b/src/el-home-applet.c index 0e683f9..97cd97d 100644 --- a/src/el-home-applet.c +++ b/src/el-home-applet.c @@ -1145,6 +1145,34 @@ query_read_events (RTComEl *el, const gchar *service, gint *events, gint *conver } static void +am_ready (OssoABookAccountManager *manager, + const GError *error, + gpointer user_data) +{ + ELHomeApplet *self = EL_HOME_APPLET (user_data); + ELHomeAppletPrivate *priv = self->priv; + + if (!error && + priv->local_id && + !GTK_WIDGET_VISIBLE (priv->icon)) { + McAccount *account; + + account = osso_abook_account_manager_lookup_by_name (NULL, + priv->local_id); + if (account) { + McProfile *profile = mc_profile_lookup (mc_account_compat_get_profile (account)); + const gchar *icon_name = mc_profile_get_icon_name (profile); + if (icon_name) { + gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon), + icon_name, + HILDON_ICON_SIZE_XSMALL); + gtk_widget_show (priv->icon); + } + } + } +} + +static void read_event (ELHomeApplet *self) { ELHomeAppletPrivate *priv = self->priv; @@ -1179,13 +1207,22 @@ read_event (ELHomeApplet *self) if (g_strcmp0 (priv->local_id, "ring/tel/ring") == 0) { icon_name = "general_sms"; } - else{ + else { McAccount *account; - account = osso_abook_account_manager_lookup_by_name (NULL, - priv->local_id); - if (account) { - McProfile *profile = mc_profile_lookup (mc_account_compat_get_profile (account)); - icon_name = mc_profile_get_icon_name (profile); + OssoABookAccountManager *am = osso_abook_account_manager_get_default (); + if (!osso_abook_waitable_is_ready (OSSO_ABOOK_WAITABLE (am), NULL)) { + osso_abook_account_manager_call_when_ready (am, + am_ready, + self, + NULL); + } + else { + account = osso_abook_account_manager_lookup_by_name (NULL, + priv->local_id); + if (account) { + McProfile *profile = mc_profile_lookup (mc_account_compat_get_profile (account)); + icon_name = mc_profile_get_icon_name (profile); + } } } -- 1.7.9.5