summaryrefslogtreecommitdiffstats
path: root/src/gui/CellRendererContact.vala
blob: 290ea09ba1cdfe91b6c444843811c4839b3e3087 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class CellRendererContact : Gtk.CellRendererText {
  private Contact _contact;
  
  public Contact contact {
    get {
      return _contact;
    }
    set {
      _contact = value;
      
      string str = escape_markup(contact.display_string);
      
      Gee.Map.Entry<string, Contact.Resource> res = contact.get_resource_with_highest_priority();
      if(res != null && res.value.status != null) {
        str += "\n<span size=\"small\" fgcolor=\"grey40\" style=\"italic\">" + escape_markup(res.value.status) + "</span>";
      }
      
      markup = str;
    }
  }
  
  public CellRendererContact() {
    ellipsize = Pango.EllipsizeMode.END;
  }
  
  private static string escape_markup(string str) {
    return str.replace("&", "&amp;").replace("\"", "&quot;").replace("<", "&lt;").replace(">", "&gt;");
  }
}