summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2010-12-14 13:08:11 +0000
committerJonny Lamb <jonnylamb@gnome.org>2010-12-15 09:30:48 +0000
commitaf5ec5fd1185cc5dc12c19157dd240af2dfb0156 (patch)
treea8d69ad90fdb34db8b2f0c6e17f653d032be08d6
parent236db35cef7b1b435847486fc935e7e374fe4adb (diff)
contact-view: use more libempathy-gtk functions
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
-rw-r--r--liszt/contact-view.c68
1 files changed, 46 insertions, 22 deletions
diff --git a/liszt/contact-view.c b/liszt/contact-view.c
index 920aa80e2..968027910 100644
--- a/liszt/contact-view.c
+++ b/liszt/contact-view.c
@@ -7,6 +7,8 @@
#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-utils.h>
+#include <libempathy-gtk/empathy-images.h>
+
G_DEFINE_TYPE (LolContactView, lol_contact_view, CLUTTER_TYPE_BOX)
/* signals */
@@ -78,39 +80,61 @@ lol_contact_view_set_avatar (LolContactView *self,
g_free (tmp);
}
+static const gchar *
+icon_name_for_presence (FolksIndividual *individual)
+{
+ FolksPresenceType folks_presence;
+ TpConnectionPresenceType presence;
+
+ folks_presence =
+ folks_presence_get_presence_type (FOLKS_PRESENCE (individual));
+ presence = empathy_folks_presence_type_to_tp (folks_presence);
+
+ switch (presence)
+ {
+ case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
+ return EMPATHY_IMAGE_AVAILABLE;
+ case TP_CONNECTION_PRESENCE_TYPE_BUSY:
+ return EMPATHY_IMAGE_BUSY;
+ case TP_CONNECTION_PRESENCE_TYPE_AWAY:
+ return EMPATHY_IMAGE_AWAY;
+ case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
+ return EMPATHY_IMAGE_IDLE;
+ case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
+ return EMPATHY_IMAGE_OFFLINE;
+ case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+ case TP_CONNECTION_PRESENCE_TYPE_ERROR:
+ return EMPATHY_IMAGE_OFFLINE;
+ case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+ return EMPATHY_IMAGE_PENDING;
+ case TP_CONNECTION_PRESENCE_TYPE_UNSET:
+ default:
+ return NULL;
+ }
+}
+
static void
lol_contact_view_set_presence (LolContactView *self,
- FolksPresenceType presence)
+ FolksIndividual *individual)
{
LolContactViewPrivate *priv = self->priv;
const gchar *icon_name = NULL;
+ gchar *tmp;
- switch (presence)
- {
- case FOLKS_PRESENCE_TYPE_AVAILABLE:
- icon_name = "/usr/share/empathy/icons/hicolor/32x32/status/user-available.png";
- break;
- case FOLKS_PRESENCE_TYPE_AWAY:
- case FOLKS_PRESENCE_TYPE_EXTENDED_AWAY:
- icon_name = "/usr/share/empathy/icons/hicolor/32x32/status/user-away.png";
- break;
- case FOLKS_PRESENCE_TYPE_HIDDEN:
- case FOLKS_PRESENCE_TYPE_BUSY:
- icon_name = "/usr/share/empathy/icons/hicolor/32x32/status/user-busy.png";
- break;
- case FOLKS_PRESENCE_TYPE_UNKNOWN:
- case FOLKS_PRESENCE_TYPE_UNSET:
- case FOLKS_PRESENCE_TYPE_OFFLINE:
- case FOLKS_PRESENCE_TYPE_ERROR:
- break;
- }
+ icon_name = icon_name_for_presence (individual);
if (icon_name == NULL)
return;
+ /* nasty */
+ tmp = g_strdup_printf (
+ "/usr/share/empathy/icons/hicolor/32x32/status/%s.png", icon_name);
+
clutter_texture_set_from_file (
CLUTTER_TEXTURE (priv->presence_texture),
- icon_name, NULL);
+ tmp, NULL);
+
+ g_free (tmp);
}
static void
@@ -126,7 +150,7 @@ lol_contact_view_update_individual (LolContactView *self)
folks_aliasable_get_alias (FOLKS_ALIASABLE (individual)),
presence_type);
- lol_contact_view_set_presence (self, presence_type);
+ lol_contact_view_set_presence (self, individual);
lol_contact_view_set_avatar (self,
folks_avatar_get_avatar (FOLKS_AVATAR (individual)));