[gnome-contacts] Add presence icons to chat details
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Add presence icons to chat details
- Date: Wed, 18 May 2011 11:40:33 +0000 (UTC)
commit 766c202ebf9b5a389bb7034cc8bc0c040972e393
Author: Alexander Larsson <alexl redhat com>
Date: Wed May 18 10:38:25 2011 +0200
Add presence icons to chat details
configure.ac | 3 ++-
src/contacts-app.vala | 22 +++++++++++++++++++++-
src/contacts-contact.vala | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7b67c2e..ce51c32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,9 +27,10 @@ AM_GLIB_GNU_GETTEXT
pkg_modules="gtk+-3.0
folks
+ folks-telepathy
"
PKG_CHECK_MODULES(CONTACTS, [$pkg_modules])
-CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg folks"
+CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg folks --pkg folks-telepathy"
AC_SUBST(CONTACTS_CFLAGS)
AC_SUBST(CONTACTS_LIBS)
AC_SUBST(CONTACTS_PACKAGES)
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index f9c11f6..0846b4d 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -151,12 +151,13 @@ public class Contacts.App : Window {
return grid;
}
- private void add_string_label (string label, string val) {
+ private Grid add_string_label (string label, string val) {
var grid = add_label(label, true, true);
var v = new Label (val);
v.set_valign (Align.CENTER);
v.set_halign (Align.START);
grid.add (v);
+ return grid;
}
private void add_string_property_label (string label, Contact contact, string pname) {
@@ -236,6 +237,25 @@ public class Contacts.App : Window {
add_string_label ("Work", "lazy example com");
}
+ var ims = contact.individual.im_addresses;
+ var im_keys = ims.get_keys ();
+ if (!im_keys.is_empty) {
+ add_label_spacer ();
+ add_label (_("Chat"), false, false);
+ foreach (var protocol in im_keys) {
+ foreach (var id in ims[protocol]) {
+ var label_grid = add_string_label (protocol, id);
+ var presence = contact.create_presence_widget (protocol, id);
+ if (presence != null) {
+ presence.set_valign (Align.CENTER);
+ presence.set_halign (Align.END);
+ presence.set_hexpand (true);
+ label_grid.add (presence);
+ }
+ }
+ }
+ }
+
add_label_spacer ();
add_string_property_label (_("Alias"), contact, "alias");
add_label_spacer ();
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 9a919d7..69480d0 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -129,6 +129,43 @@ public class Contacts.Contact : GLib.Object {
return iconname;
}
+ public Persona? find_im_persona (string protocol, string im_address) {
+ foreach (var p in individual.personas) {
+ var iid = protocol + ":" + im_address;
+ var tp = p as Tpf.Persona;
+ if (tp != null && tp.iid == iid) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+ public Widget? create_presence_widget (string protocol, string im_address) {
+ var tp = find_im_persona (protocol, im_address);
+ if (tp == null)
+ return null;
+
+ var presence_details = tp as PresenceDetails;
+ if (presence_details == null)
+ return null;
+
+ var i = new Image ();
+ i.set_from_icon_name (presence_to_icon (presence_details.presence_type), IconSize.BUTTON);
+ i.set_tooltip_text (presence_details.presence_message);
+
+ var id1 = tp.notify["presence-type"].connect ((pspec) => {
+ i.set_from_icon_name (presence_to_icon (presence_details.presence_type), IconSize.BUTTON);
+ });
+ var id2 = tp.notify["presence-message"].connect ( (pspec) => {
+ i.set_tooltip_text (presence_details.presence_message);
+ });
+ i.destroy.connect (() => {
+ tp.disconnect(id1);
+ tp.disconnect(id2);
+ });
+ return i;
+ }
+
private bool changed_cb () {
changed_id = 0;
update ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]