fix acronyms expander plugin

This commit is contained in:
Yann Leboulanger 2010-02-12 20:41:21 +01:00
parent ad8c7a0f41
commit 73a4c4e1b9
1 changed files with 7 additions and 10 deletions

View File

@ -27,6 +27,7 @@ Acronyms expander plugin.
import sys
import gtk
import gobject
from plugins import GajimPlugin
from plugins.helpers import log, log_calls
@ -70,19 +71,15 @@ class AcronymsExpanderPlugin(GajimPlugin):
t = tb.get_text(tb.get_start_iter(), tb.get_end_iter())
#log.debug('%s %d'%(t, len(t)))
if t and t[-1] == INVOKER:
#log.debug("changing msg text")
#log.debug('changing msg text')
base,sep,head=t[:-1].rpartition(INVOKER)
#log.debug('%s | %s | %s'%(base, sep, head))
log.debug('%s | %s | %s'%(base, sep, head))
if head in ACRONYMS:
head = ACRONYMS[head]
log.debug("head: %s"%(head))
t = "".join((base, sep, head, INVOKER))
#log.debug("turning off notify")
tb.freeze_notify()
#log.debug('head: %s'%(head))
t = ''.join((base, sep, head, INVOKER))
#log.debug("setting text: '%s'"%(t))
tb.set_text(t)
#log.debug("turning on notify")
tb.thaw_notify()
gobject.idle_add(tb.set_text, t)
@log_calls('AcronymsExpanderPlugin')
def connect_with_chat_control_base(self, chat_control):
@ -101,4 +98,4 @@ class AcronymsExpanderPlugin(GajimPlugin):
d = chat_control.acronyms_expander_plugin_data
tv = chat_control.msg_textview
tv.get_buffer().disconnect(d['h_id'])