Skip to content

Commit

Permalink
Merge pull request #1 from Smotko/master
Browse files Browse the repository at this point in the history
Updated for 3.1.92/3.2 and some group chat fixes
  • Loading branch information
BigE committed Sep 28, 2011
2 parents a03861e + f09e1a0 commit c1270ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
28 changes: 22 additions & 6 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Tp = imports.gi.TelepathyGLib;
const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;

function wrappedText(text, sender, timestamp, direction) {
function wrappedText(text, sender, timestamp, direction, chat) {
let currentTime = (Date.now() / 1000);
let type = Tp.ChannelTextMessageType.NORMAL;

Expand All @@ -30,6 +30,9 @@ function wrappedText(text, sender, timestamp, direction) {
}

text = _fixText(text);
if (chat && direction != TelepathyClient.NotificationDirection.SENT){
text = sender + ": " + text;
}
if (text.substr(0, 3) == '/me' && direction != TelepathyClient.NotificationDirection.SENT) {
text = text.substr(4);
type = Tp.ChannelTextMessageType.ACTION;
Expand Down Expand Up @@ -98,6 +101,7 @@ Source.prototype = {
this._notification.enableScrolling(true);

proxy.PurpleConversationGetTitleRemote(this._conversation, Lang.bind(this, this._async_set_title));
if (chat) proxy.PurpleConvChatRemote(this._conversation, Lang.bind(this, this._async_set_conversation_im));
},

_async_set_author_buddy: function (author_buddy) {
Expand Down Expand Up @@ -152,8 +156,8 @@ Source.prototype = {
} else if (this._initialFlag == 2) {
direction = TelepathyClient.NotificationDirection.RECEIVED;
}

let message = wrappedText(this._initialMessage, this._author, null, direction);
let message = wrappedText(this._initialMessage, this._author, null, direction, this._chat);
this._notification.appendMessage(message, false);

if (this._chat) {
Expand Down Expand Up @@ -218,7 +222,12 @@ Source.prototype = {
respond: function(text) {
let proxy = this._client.proxy();
let _text = GLib.markup_escape_text(text, -1);
proxy.PurpleConvImSendRemote(this._conversation_im, _text);
if(this._chat){
proxy.PurpleConvChatSendRemote(this._conversation_im, _text);
}
else{
proxy.PurpleConvImSendRemote(this._conversation_im, _text);
}
},

_onBuddyStatusChange: function (emitter, buddy, old_status_id, new_status_id) {
Expand Down Expand Up @@ -299,18 +308,23 @@ Source.prototype = {
},

_onDisplayedChatMessage: function(emitter, account, author, text, conversation, flag) {

global.log(flag);
if (text && (this._conversation == conversation) && (flag & 3) == 2) {
// accept messages from people who sent us something with our nick in it
if ((flag & 32) == 32) {
this._authors[author] = true;
}
if (author in this._authors) {
let message = wrappedText(text, author, null, TelepathyClient.NotificationDirection.RECEIVED);
let message = wrappedText(text, author, null, TelepathyClient.NotificationDirection.RECEIVED, this._chat);
this._notification.appendMessage(message, false);
this.notify();
}
}
else if(flag == 1){
let message = wrappedText(text, author, null, TelepathyClient.NotificationDirection.SENT, this._chat);
this._notification.appendMessage(message, false);
this.notify();
}

},

Expand Down Expand Up @@ -355,7 +369,9 @@ const PidginIface = {
{name: 'PurpleBuddyIconGetFullPath', inSignature: 'i', outSignature: 's'},
{name: 'PurpleBuddyGetIcon', inSignature: 'i', outSignature: 'i'},
{name: 'PurpleConvImSend', inSignature: 'is', outSignature: ''},
{name: 'PurpleConvChatSend', inSignature: 'is', outSignature: ''},
{name: 'PurpleConvIm', inSignature: 'i', outSignature: 'i'},
{name: 'PurpleConvChat', inSignature: 'i', outSignature: 'i'},
{name: 'PurpleConvImGetIcon', inSignature: 'i', outSignature: 'i'},
{name: 'PurpleConversationGetName', inSignature: 'i', outSignature: 's'},
{name: 'PurpleConversationGetAccount', inSignature: 'i', outSignature: 's'},
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"uuid": "[email protected]",
"name": "Pidgin IM Integration",
"description": "Display Pidgin chats as notifications in the Shell message tray.",
"shell-version": [ "3.1.91" ],
"shell-version": [ "3.1.91", "3.1.92", "3.2" ],
"localedir": "/usr/share/locale",
"url": "https://github.com/kagesenshi/gnome-shell-extensions-pidgin"
}

0 comments on commit c1270ef

Please sign in to comment.