[gnome-shell] telepathyClient: Add alias change notifiers



commit 8c40c2086aac9d252c51150a9ac5f4760ba352dc
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Feb 28 13:15:02 2011 -0500

    telepathyClient: Add alias change notifiers
    
    Update the Source title when an contact's alias changes, and
    also also add a minor meta message like the current timestamps.
    
    Updating the alias of a 'presenced' contact will overwrite the
    current title, and it will also not update the summary item title
    right now due to limitations of the message tray.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=642793

 js/ui/telepathyClient.js |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js
index 7bfc7ac..ab90579 100644
--- a/js/ui/telepathyClient.js
+++ b/js/ui/telepathyClient.js
@@ -116,7 +116,7 @@ Source.prototype = {
     __proto__:  MessageTray.Source.prototype,
 
     _init: function(account, conn, channel, contact) {
-        MessageTray.Source.prototype._init.call(this, channel.get_identifier());
+        MessageTray.Source.prototype._init.call(this, contact.get_alias());
 
         this.isChat = true;
 
@@ -127,8 +127,6 @@ Source.prototype = {
         this._channel = channel;
         this._closedId = this._channel.connect('invalidated', Lang.bind(this, this._channelClosed));
 
-        this._updateAlias();
-
         this._notification = new Notification(this);
         this._notification.setUrgency(MessageTray.Urgency.HIGH);
 
@@ -151,7 +149,10 @@ Source.prototype = {
     },
 
     _updateAlias: function() {
+        let oldAlias = this.title;
         this.title = this._contact.get_alias();
+        this._notification.appendAliasChange(oldAlias, this.title);
+        this.pushNotification(this._notification);
     },
 
     createNotificationIcon: function() {
@@ -373,6 +374,19 @@ Notification.prototype = {
         this._history.unshift({ actor: label, time: (Date.now() / 1000), realMessage: false});
     },
 
+    appendAliasChange: function(oldAlias, newAlias) {
+        oldAlias = GLib.markup_escape_text(oldAlias, -1);
+        newAlias = GLib.markup_escape_text(newAlias, -1);
+
+        /* Translators: this is the other person changing their old IM name to their new
+           IM name. */
+        let message = '<i>' + _("%s is now known as %s").format(oldAlias, newAlias) + '</i>';
+        let label = this.addBody(message, true);
+        label.add_style_class_name('chat-meta-message');
+        this._history.unshift({ actor: label, time: (Date.now() / 1000), realMessage: false });
+        this.update(newAlias, null, { customContent: true });
+    },
+
     _onEntryActivated: function() {
         let text = this._responseEntry.get_text();
         if (text == '')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]