[gnome-contacts/new-design] Handle sensitivity for chat and call buttons



commit 21a678bfcedef2032cd572d4770676ccdbe2f9c3
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Dec 16 11:44:35 2011 +0100

    Handle sensitivity for chat and call buttons

 src/contacts-contact-pane.vala |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 59bf3c7..53d2408 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -1855,6 +1855,33 @@ public class Contacts.ContactPane : ScrolledWindow {
   public void update_buttons () {
     var emails = contact.individual.email_addresses;
     email_button.set_sensitive (!emails.is_empty);
+
+    var ims = contact.individual.im_addresses;
+    var im_keys = ims.get_keys ();
+    bool found_im = false;
+    bool callable = false;
+    if (contact != null) {
+      foreach (var protocol in im_keys) {
+	foreach (var id in ims[protocol]) {
+	  var im_persona = contact.find_im_persona (protocol, id.value);
+	  if (im_persona != null) {
+	    var type = im_persona.presence_type;
+	    if (type != PresenceType.UNSET &&
+		type != PresenceType.ERROR &&
+		type != PresenceType.OFFLINE)
+	      found_im = true;
+	  }
+
+	  if (contact.is_callable (protocol, id.value) != null)
+	    callable = true;
+	}
+      }
+    }
+    chat_button.set_sensitive (found_im);
+    if (callable)
+      call_button.show ();
+    else
+      call_button.hide ();
   }
 
   public void update_personas () {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]