From a20742c57995b3dc4cc264585ab3b79ca142261b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 23 Jun 2010 03:38:37 +0200 Subject: Show resource in tooltip --- src/gui/Contact.vala | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'src/gui/Contact.vala') diff --git a/src/gui/Contact.vala b/src/gui/Contact.vala index 1db1e62..d79cfff 100644 --- a/src/gui/Contact.vala +++ b/src/gui/Contact.vala @@ -9,26 +9,51 @@ public class Contact : Object { public Contact(string jid0, string? name0) { Object(jid: jid0, name: name0); + + update_display_string(); } public class Resource : Object { + public Resource(int prio0, Show show0, string? status0) { + Object(priority: prio0, show: show0, status: status0); + } + public int priority {get; construct;} public Show show {get; construct;} - public string status {get; construct;} + public string? status {get; construct;} } public string jid {get; construct;} public string? name {get; construct;} public Subscription subscription {get; set;} - public Gee.TreeSet groups; - public Gee.HashMap resources {get; private set;} - - public string display_string { - get { - if (name != null) - return name; - else - return jid; + public Gee.TreeSet groups = new Gee.TreeSet(); + public string display_string {get; private set;} + + private Gee.HashMap resources = new Gee.HashMap(); + + private void update_display_string() { + if (name != null) + display_string = name; + else + display_string = jid; + } + + public Gee.Map.Entry? get_resource_with_highest_priority() { + int max_prio = int.MIN; + Gee.Map.Entry ret = null; + + foreach(Gee.Map.Entry res in resources) { + if(res.value.priority > max_prio) { + max_prio = res.value.priority; + ret = res; + } } + + return ret; + } + + public void update_resource(string resource_name, Resource resource) { + resources[resource_name] = resource; + update_display_string(); } } -- cgit v1.2.3