diff options
Diffstat (limited to 'liszt/contact-view.c')
-rw-r--r-- | liszt/contact-view.c | 126 |
1 files changed, 83 insertions, 43 deletions
diff --git a/liszt/contact-view.c b/liszt/contact-view.c index 979857e79..86d57b35c 100644 --- a/liszt/contact-view.c +++ b/liszt/contact-view.c @@ -34,6 +34,10 @@ struct _LolContactViewPrivate ClutterActor *avatar_texture; ClutterActor *actions; + ClutterActor *chat_button; + ClutterActor *audio_button; + ClutterActor *video_button; + gboolean selected; }; @@ -87,7 +91,7 @@ icon_name_for_presence (FolksIndividual *individual) TpConnectionPresenceType presence; folks_presence = - folks_presence_get_presence_type (FOLKS_PRESENCE (individual)); + folks_has_presence_get_presence_type (FOLKS_HAS_PRESENCE (individual)); presence = empathy_folks_presence_type_to_tp (folks_presence); switch (presence) @@ -137,14 +141,81 @@ lol_contact_view_set_presence (LolContactView *self, g_free (tmp); } +static TpContact * +get_contact_and_account (LolContactView *self, + TpAccount **account) +{ + LolContactViewPrivate *priv = self->priv; + GList *personas, *l; + FolksPersona *persona = NULL; + FolksPersonaStore *store; + TpContact *contact; + + personas = folks_individual_get_personas (priv->individual); + + for (l = personas; l != NULL; l = l->next) + { + if (!TPF_IS_PERSONA (l->data)) + continue; + + persona = l->data; + break; + } + + if (persona == NULL) + return NULL; + + store = folks_persona_get_store (persona); + contact = tpf_persona_get_contact (TPF_PERSONA (persona)); + + if (account != NULL) + *account = tpf_persona_store_get_account (TPF_PERSONA_STORE (store)); + + return contact; +} + static void -lol_contact_view_update_individual (LolContactView *self) +lol_contact_view_update_capabilities (LolContactView *self) { + LolContactViewPrivate *priv = self->priv; + + TpContact *contact; + EmpathyContact *e_contact = NULL; + EmpathyCapabilities capabilities = EMPATHY_CAPABILITIES_NONE; + + contact = get_contact_and_account (self, NULL); + if (contact != NULL) + { + e_contact = empathy_contact_dup_from_tp_contact (contact); + capabilities = empathy_contact_get_capabilities (e_contact); + } + + if (capabilities != EMPATHY_CAPABILITIES_NONE) + clutter_actor_show (priv->chat_button); + else + clutter_actor_hide (priv->chat_button); + + if (capabilities & EMPATHY_CAPABILITIES_AUDIO) + clutter_actor_show (priv->audio_button); + else + clutter_actor_hide (priv->audio_button); + if (capabilities & EMPATHY_CAPABILITIES_VIDEO) + clutter_actor_show (priv->video_button); + else + clutter_actor_hide (priv->video_button); + + if (e_contact != NULL) + g_object_unref (e_contact); +} + +static void +lol_contact_view_update_individual (LolContactView *self) +{ FolksIndividual *individual = self->priv->individual; FolksPresenceType presence_type; - presence_type = folks_presence_get_presence_type (FOLKS_PRESENCE (individual)); + presence_type = folks_has_presence_get_presence_type (FOLKS_HAS_PRESENCE (individual)); lol_contact_view_set_markup (self, folks_aliasable_get_alias (FOLKS_ALIASABLE (individual)), @@ -153,7 +224,9 @@ lol_contact_view_update_individual (LolContactView *self) lol_contact_view_set_presence (self, individual); lol_contact_view_set_avatar (self, - folks_avatar_get_avatar (FOLKS_AVATAR (individual))); + folks_has_avatar_get_avatar (FOLKS_HAS_AVATAR (individual))); + + lol_contact_view_update_capabilities (self); /* online */ if (presence_type > FOLKS_PRESENCE_TYPE_OFFLINE @@ -223,39 +296,6 @@ lol_contact_view_get_property (GObject *object, } } -static TpContact * -get_contact_and_account (LolContactView *self, - TpAccount **account) -{ - LolContactViewPrivate *priv = self->priv; - GList *personas, *l; - FolksPersona *persona; - FolksPersonaStore *store; - TpContact *contact; - - personas = folks_individual_get_personas (priv->individual); - - for (l = personas; l != NULL; l = l->next) - { - if (!TPF_IS_PERSONA (l->data)) - continue; - - persona = l->data; - break; - } - - if (persona == NULL) - return NULL; - - store = folks_persona_get_store (persona); - contact = tpf_persona_get_contact (TPF_PERSONA (persona)); - - if (account != NULL) - *account = tpf_persona_store_get_account (TPF_PERSONA_STORE (store)); - - return contact; -} - static void chat_clicked_cb (MxButton *button, LolContactView *self) @@ -382,7 +422,7 @@ lol_contact_view_constructed (GObject *obj) priv->actions = clutter_box_new (CLUTTER_LAYOUT_MANAGER (layout)); clutter_actor_set_height (priv->actions, 32.0); - button = mx_button_new_with_label ("Chat"); + button = priv->chat_button = mx_button_new_with_label ("Chat"); clutter_box_pack (CLUTTER_BOX (priv->actions), button, "expand", FALSE, "x-fill", FALSE, @@ -390,10 +430,10 @@ lol_contact_view_constructed (GObject *obj) NULL); clutter_box_layout_set_alignment (layout, button, CLUTTER_BOX_ALIGNMENT_START, CLUTTER_BOX_ALIGNMENT_START); - + clutter_actor_hide (button); g_signal_connect (button, "clicked", G_CALLBACK (chat_clicked_cb), self); - button = mx_button_new_with_label ("Audio Call"); + priv->audio_button = button = mx_button_new_with_label ("Audio Call"); clutter_box_pack (CLUTTER_BOX (priv->actions), button, "expand", FALSE, "x-fill", FALSE, @@ -401,10 +441,10 @@ lol_contact_view_constructed (GObject *obj) NULL); clutter_box_layout_set_alignment (layout, button, CLUTTER_BOX_ALIGNMENT_START, CLUTTER_BOX_ALIGNMENT_START); - + clutter_actor_hide (button); g_signal_connect (button, "clicked", G_CALLBACK (audio_call_clicked_cb), self); - button = mx_button_new_with_label ("Video Call"); + priv->video_button = button = mx_button_new_with_label ("Video Call"); clutter_box_pack (CLUTTER_BOX (priv->actions), button, "expand", FALSE, "x-fill", FALSE, @@ -412,7 +452,7 @@ lol_contact_view_constructed (GObject *obj) NULL); clutter_box_layout_set_alignment (layout, button, CLUTTER_BOX_ALIGNMENT_START, CLUTTER_BOX_ALIGNMENT_START); - + clutter_actor_hide (button); g_signal_connect (button, "clicked", G_CALLBACK (video_call_clicked_cb), self); clutter_box_pack (CLUTTER_BOX (obj), priv->actions, |