diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index 59973cf5f..82cd6cd1f 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -572,7 +572,8 @@ Copyright © 2003-2005 Gajim Team <b>Gajim Team</b> Vincent Hanquez (tab@snarc.org) Yann Le Boulanger (asterix@lagaule.org) -Nikos Kouremenos (nkour@jabber.org) +Nikos Kouremenos (nkour@jabber.org) +Alex Podaras (bigpod@jabber.org) False True GTK_JUSTIFY_LEFT @@ -4826,7 +4827,7 @@ Custom True - Browser + Browser: False False GTK_JUSTIFY_LEFT @@ -4850,7 +4851,7 @@ Custom True - Mail app + Mail : False False GTK_JUSTIFY_LEFT diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index 33a7f5464..13a750446 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -365,6 +365,9 @@ class tabbed_chat_window: if len(self.xmls) == 1: self.chat_notebook.set_show_tabs(False) self.show_title() + + def hyperlink_handler(self, *args): + pass def new_user(self, user): self.nb_unread[user.jid] = 0 @@ -374,7 +377,9 @@ class tabbed_chat_window: conversation_textview = \ self.xmls[user.jid].get_widget('conversation_textview') conversation_buffer = conversation_textview.get_buffer() + self.link_tag = conversation_buffer.create_tag('hyperlink', foreground='blue') end_iter = conversation_buffer.get_end_iter() + self.link_tag.connect('event', self.hyperlink_handler) conversation_buffer.create_mark('end', end_iter, 0) self.tagIn[user.jid] = conversation_buffer.create_tag('incoming') color = self.plugin.config['inmsgcolor'] @@ -545,7 +550,25 @@ class tabbed_chat_window: index+=l beg = index index+=1 - conversation_buffer.insert(end_iter, otext[beg:]) + #conversation_buffer.insert(end_iter, otext[beg:]) + + linksprefix = ['http://', 'https://', 'news://', 'ftp://', 'mailto:', 'ed2k://', 'www.', 'ftp.'] + start=0 + otext_lowered = otext.lower() # make them all small letters + for word in otext_lowered.split(): # get each word seperately + # word must be larger than the linksprefix items which atm the smaller is 4 + if len(word) > 4: + for travelthru in range(len(linksprefix)): # travel tru linksprefix list + # linksprefix[travelthru] is http:// then https:// then news:// etc.. + if word.startswith(linksprefix[travelthru]): + start = otext_lowered.index(word) + end = start + len(word) + print word, 'is a link and is in otext[%s:%s]' % (start, end) + conversation_buffer.insert_with_tags_by_name(end_iter, otext[start:end], 'hyperlink') + end_iter = conversation_buffer.get_end_iter() + break + + conversation_buffer.insert(end_iter, otext[start:]) #scroll to the end of the textview conversation_textview.scroll_to_mark(conversation_buffer.get_mark('end'),\