Esempio n. 1
0
 def set_text (self, txt):
     m = self.href_regexp.search(txt)
     if m:
         while m:
             href = m.groups()[0]
             body = m.groups()[1]
             if self.markup_dict.has_key(body) and self.markup_dict[body]!=href:
                 raise Exception("""Damn -- our not-so-clever implementation of <a href=""> parsing requires
                 that no two distinct links have the same text describing them!""")
             self.markup_dict[body]=href
             m = self.href_regexp.search(txt,m.end())
         txt = self.href_regexp.sub(r'<span %s>\2</span>'%self.url_markup,txt)
     PangoBuffer.set_text(self,txt)
Esempio n. 2
0
 def insert_with_tags(self, itr, text, *tags):
     match = True
     for p, v in self.url_props:
         match = False
         for t in tags:
             if isinstance(v, gtk.gdk.Color):
                 c = t.get_property(p)
                 if v.red == c.red and v.blue == c.blue and v.green == c.green:
                     match = True
             elif t.get_property(p) == v:
                 match = True
         if not match:
             break
     text = unicode(text)
     if match and self.markup_dict.has_key(text):
         new_tag = self.create_tag()
         new_tag.set_data("href", self.markup_dict[text])
         tags = list(tags)
         tags.append(new_tag)
     elif match:
         print "Funny", text, "looks like a link, but is not in markup_dict", self.markup_dict
     PangoBuffer.insert_with_tags(self, itr, text, *tags)
Esempio n. 3
0
 def insert_with_tags(self, itr, text, *tags):
     match = True
     for p, v in self.url_props:
         match = False
         for t in tags:
             if isinstance(v, gtk.gdk.Color):
                 c = t.get_property(p)
                 if v.red == c.red and v.blue == c.blue and v.green == c.green:
                     match = True
             elif t.get_property(p) == v:
                 match = True
         if not match:
             break
     text = unicode(text)
     if match and self.markup_dict.has_key(text):
         new_tag = self.create_tag()
         new_tag.set_data('href', self.markup_dict[text])
         tags = list(tags)
         tags.append(new_tag)
     elif match:
         print 'Funny', text, 'looks like a link, but is not in markup_dict', self.markup_dict
     PangoBuffer.insert_with_tags(self, itr, text, *tags)