[kupfer] plugin.pidgin: Tell pidgin to present conversation in OpenChat



commit ced5a8c942040cfcb0a8a0fb1f5573a4a7a6fe2d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Oct 30 15:35:48 2009 +0100

    plugin.pidgin: Tell pidgin to present conversation in OpenChat
    
    We try to focus the new conversation in the OpenChat action by telling
    Pidgin to present it.
    
    There are some problems that are not easy to work around in Kupfer:
    
    Tabs do not switch automatically, this is a bug in Pidgin. Also,
    window focusing does not work perfectly with already open chat windows
    due to "focus stealing prevention".

 kupfer/plugin/pidgin.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/plugin/pidgin.py b/kupfer/plugin/pidgin.py
index 834a556..8be71d6 100644
--- a/kupfer/plugin/pidgin.py
+++ b/kupfer/plugin/pidgin.py
@@ -44,7 +44,7 @@ def _create_dbus_connection(activate=False):
 	return interface
 
 
-def _send_message_to_contact(pcontact, message):
+def _send_message_to_contact(pcontact, message, present=False):
 	"""
 	Send @message to PidginContact @pcontact
 	"""
@@ -55,6 +55,14 @@ def _send_message_to_contact(pcontact, message):
 	conversation = interface.PurpleConversationNew(1, account, jid)
 	im = interface.PurpleConvIm(conversation)
 	interface.PurpleConvImSend(im, message)
+	if present:
+		interface.PurpleConversationPresent(conversation)
+
+def _open_chat_with_contact(pcontact):
+	interface = _create_dbus_connection()
+	if not interface:
+		return
+	account, jid = pcontact.account, pcontact.jid
 
 
 class OpenChat(Action):
@@ -64,7 +72,7 @@ class OpenChat(Action):
 		Action.__init__(self, _('Open Chat'))
 
 	def activate(self, leaf):
-		_send_message_to_contact(leaf, u"")
+		_send_message_to_contact(leaf, u"", present=True)
 
 class SendMessage (Action):
 	""" Send chat message directly from Kupfer """



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