[gnome-contacts] Make chat details have a Chat label
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Make chat details have a Chat label
- Date: Wed, 8 Jun 2011 20:35:12 +0000 (UTC)
commit a9c569f1ac468c81e86ee73029adea4bfdc387ff
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jun 8 12:49:13 2011 +0200
Make chat details have a Chat label
src/contacts-app.vala | 32 ++++++++++++++------------------
src/contacts-contact.vala | 20 ++++++++++----------
2 files changed, 24 insertions(+), 28 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index f2b10a5..0e8d7c2 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -299,7 +299,7 @@ public class Contacts.App : Window {
if (!im_keys.is_empty) {
foreach (var protocol in im_keys) {
foreach (var id in ims[protocol]) {
- add_string_label (protocol, id, out row);
+ add_string_label (_("Chat"), contact.format_im_name (protocol, id), out row);
Button? button = null;
var presence = contact.create_presence_widget (protocol, id);
if (presence != null) {
@@ -307,24 +307,20 @@ public class Contacts.App : Window {
button.add (presence);
}
- var im_persona = contact.find_im_persona (protocol, id);
-
- if (button != null && im_persona != null) {
+ if (button != null) {
button.clicked.connect ( () => {
- try {
- var account = (im_persona.store as Tpf.PersonaStore).account;
- var request_dict = new HashTable<weak string,GLib.Value?>(str_hash, str_equal);
- request_dict.insert (TelepathyGLib.PROP_CHANNEL_CHANNEL_TYPE, TelepathyGLib.IFACE_CHANNEL_TYPE_TEXT);
- request_dict.insert (TelepathyGLib.PROP_CHANNEL_TARGET_HANDLE_TYPE, (int) TelepathyGLib.HandleType.CONTACT);
- request_dict.insert (TelepathyGLib.PROP_CHANNEL_TARGET_ID, id);
-
- // TODO: Should really use the event time like:
- // tp_user_action_time_from_x11(gtk_get_current_event_time())
- var request = new TelepathyGLib.AccountChannelRequest(account, request_dict, int64.MAX);
- request.ensure_channel_async.begin ("org.freedesktop.Telepathy.Client.Empathy.Chat", null);
- } catch {
- }
- });
+ var im_persona = contact.find_im_persona (protocol, id);
+ var account = (im_persona.store as Tpf.PersonaStore).account;
+ var request_dict = new HashTable<weak string,GLib.Value?>(str_hash, str_equal);
+ request_dict.insert (TelepathyGLib.PROP_CHANNEL_CHANNEL_TYPE, TelepathyGLib.IFACE_CHANNEL_TYPE_TEXT);
+ request_dict.insert (TelepathyGLib.PROP_CHANNEL_TARGET_HANDLE_TYPE, (int) TelepathyGLib.HandleType.CONTACT);
+ request_dict.insert (TelepathyGLib.PROP_CHANNEL_TARGET_ID, id);
+
+ // TODO: Should really use the event time like:
+ // tp_user_action_time_from_x11(gtk_get_current_event_time())
+ var request = new TelepathyGLib.AccountChannelRequest(account, request_dict, int64.MAX);
+ request.ensure_channel_async.begin ("org.freedesktop.Telepathy.Client.Empathy.Chat", null);
+ });
}
}
}
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 50ff788..92551ce 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -182,17 +182,21 @@ public class Contacts.Contact : GLib.Object {
return lines;
}
- public Persona? find_im_persona (string protocol, string im_address) {
+ public Tpf.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 tp;
}
}
return null;
}
+ public string format_im_name (string protocol, string id) {
+ return id + " (" + protocol + ")";
+ }
+
private void update_presence_widgets (Image image, Label label) {
if (individual.presence_type == PresenceType.UNSET) {
image.clear ();
@@ -247,19 +251,15 @@ public class Contacts.Contact : GLib.Object {
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_full (presence_details.presence_type), IconSize.MENU);
- i.set_tooltip_text (presence_details.presence_message);
+ i.set_from_icon_name (presence_to_icon_full (tp.presence_type), IconSize.MENU);
+ i.set_tooltip_text (tp.presence_message);
var id1 = tp.notify["presence-type"].connect ((pspec) => {
- i.set_from_icon_name (presence_to_icon_full (presence_details.presence_type), IconSize.MENU);
+ i.set_from_icon_name (presence_to_icon_full (tp.presence_type), IconSize.MENU);
});
var id2 = tp.notify["presence-message"].connect ( (pspec) => {
- i.set_tooltip_text (presence_details.presence_message);
+ i.set_tooltip_text (tp.presence_message);
});
i.destroy.connect (() => {
tp.disconnect(id1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]