[gnome-contacts] Break out presence to icon-name mapping
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Break out presence to icon-name mapping
- Date: Wed, 18 May 2011 11:40:28 +0000 (UTC)
commit 2231941058fa2bd6d46afc4dbb3a454797368af6
Author: Alexander Larsson <alexl redhat com>
Date: Wed May 18 10:35:49 2011 +0200
Break out presence to icon-name mapping
src/contacts-app.vala | 15 +--------------
src/contacts-contact.vala | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index bc5e85e..f9c11f6 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -74,20 +74,7 @@ public class Contacts.App : Window {
model.get (iter, 0, out contact);
Individual individual = contact.individual;
- string? iconname = null;
- switch (individual.presence_type) {
- case PresenceType.AVAILABLE:
- case PresenceType.UNKNOWN:
- iconname = "user-available-symbolic";
- break;
- case PresenceType.AWAY:
- case PresenceType.EXTENDED_AWAY:
- iconname = "user-away-symbolic";
- break;
- case PresenceType.BUSY:
- iconname = "user-busy-symbolic";
- break;
- }
+ string? iconname = Contact.presence_to_icon (individual.presence_type);
cell.set ("visible", icon != null);
if (icon != null)
cell.set ("icon-name", iconname);
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 6a65334..9a919d7 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -103,6 +103,32 @@ public class Contacts.Contact : GLib.Object {
return true;
}
+ public static string presence_to_icon (PresenceType presence) {
+ string? iconname = null;
+ switch (presence) {
+ default:
+ case PresenceType.OFFLINE:
+ case PresenceType.UNSET:
+ case PresenceType.ERROR:
+ break;
+ case PresenceType.AVAILABLE:
+ case PresenceType.UNKNOWN:
+ iconname = "user-available-symbolic";
+ break;
+ case PresenceType.AWAY:
+ case PresenceType.EXTENDED_AWAY:
+ iconname = "user-away-symbolic";
+ break;
+ case PresenceType.BUSY:
+ iconname = "user-busy-symbolic";
+ break;
+ case PresenceType.HIDDEN:
+ iconname = "user-invisible-symbolic";
+ break;
+ }
+ return iconname;
+ }
+
private bool changed_cb () {
changed_id = 0;
update ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]