def isrtl(self, element): '''Returns True if the parse tree below element starts with characters in a RTL script. This is e.g. needed to produce correct HTML output. Returns None if direction is not determined. ''' if pango is None: return None # It seems the find_base_dir() function is not documented in the # python language bindings. The Gtk C code shows the signature: # # pango.find_base_dir(text, length) # # It either returns a direction, or NEUTRAL if e.g. text only # contains punctuation but no real characters. if element.text: dir = pango.find_base_dir(element.text, len(element.text)) if not dir == pango.DIRECTION_NEUTRAL: return dir == pango.DIRECTION_RTL for child in element.getchildren(): rtl = self.isrtl(child) if not rtl is None: return rtl if element.tail: dir = pango.find_base_dir(element.tail, len(element.tail)) if not dir == pango.DIRECTION_NEUTRAL: return dir == pango.DIRECTION_RTL return None
def getRTL(self, message): '''check whether it's an right-to-left string''' try: if pango.find_base_dir(message, -1) == pango.DIRECTION_RTL: return '1' finally: return '0'
def _update_base(self, elements_list=None): if elements_list is None: elements_list = [''] self._smilies = {} self._base_attrlist = pango.AttrList() text = '' if isinstance(elements_list, basestring): elements_list = [elements_list] for element in elements_list: if isinstance(element, basestring): try: attrl, ptxt, unused = pango.parse_markup(element, u'\x00') except: attrl, ptxt = pango.AttrList(), element #append attribute list shift = len(text) itter = attrl.get_iterator() while True: attrs = itter.get_attrs() for attr in attrs: attr.end_index += shift attr.start_index += shift self._base_attrlist.insert(attr) if not itter.next(): break text += ptxt elif isinstance(element, gtk.gdk.Pixbuf): self._smilies[len(text)] = element text += '_' pango.Layout.set_text(self, text) if hasattr(pango, 'find_base_dir'): for line in text.splitlines(): if (pango.find_base_dir(line, -1) == pango.DIRECTION_RTL): self._is_rtl = True break else: self._is_rtl = False logical = self.get_line(0).get_pixel_extents()[1] ascent = pango.ASCENT(logical) decent = pango.DESCENT(logical) self._text_height = ascent + decent self._base_to_center = (self._text_height // 2) - decent self._update_smilies()
def _update_base(self, elements_list=None): if elements_list is None: elements_list = [''] self._smilies = {} self._base_attrlist = pango.AttrList() text = '' if type(elements_list) in (str, unicode): elements_list = [elements_list] for element in elements_list: if type(element) in (str, unicode): try: attrl, ptxt, unused = pango.parse_markup(element, u'\x00') except: attrl, ptxt = pango.AttrList(), element #append attribute list shift = len(text) itter = attrl.get_iterator() while True: attrs = itter.get_attrs() for attr in attrs: attr.end_index += shift attr.start_index += shift self._base_attrlist.insert(attr) if not itter.next(): break text += ptxt elif type(element) == gtk.gdk.Pixbuf: self._smilies[len(text)] = element text += '_' pango.Layout.set_text(self, text) if hasattr(pango, 'find_base_dir'): for line in text.splitlines(): if (pango.find_base_dir(line, -1) == pango.DIRECTION_RTL): self._is_rtl = True break else: self._is_rtl = False logical = self.get_line(0).get_pixel_extents()[1] ascent = pango.ASCENT(logical) decent = pango.DESCENT(logical) self._text_height = ascent + decent self._base_to_center = (self._text_height // 2) - decent self._update_smilies()
def isrtl(self, text): '''Check for Right To Left script @param text: the text to check @returns: C{True} if C{text} starts with characters in a RTL script, or C{None} if direction is not determined. ''' if pango is None: return None # It seems the find_base_dir() function is not documented in the # python language bindings. The Gtk C code shows the signature: # # pango.find_base_dir(text, length) # # It either returns a direction, or NEUTRAL if e.g. text only # contains punctuation but no real characters. dir = pango.find_base_dir(text, len(text)) if dir == pango.DIRECTION_NEUTRAL: return None else: return dir == pango.DIRECTION_RTL
def _update_base(self, elements_list=['']): self._smilies = {} self._base_attrlist = pango.AttrList() text = '' if type(elements_list) in (str, unicode): elements_list = [elements_list] for element in elements_list: if type(element) in (str, unicode): try: attrl, ptxt, ac = pango.parse_markup(str(element), u'\x00') except: attrl, ptxt = pango.AttrList(), str(element) shift = len(text) itter = attrl.get_iterator() while True: attrs = itter.get_attrs() for attr in attrs: attr.end_index += shift attr.start_index += shift self._base_attrlist.insert(attr) if not itter.next(): break text += ptxt elif type(element) == Smiley: self._smilies[len(text)] = element.getPixbuf(animated=False) text += '_' pango.Layout.set_text(self, text) if hasattr(pango, 'find_base_dir'): for line in text.splitlines(): if (pango.find_base_dir(line,-1) == pango.DIRECTION_RTL): self._is_rtl = True break else: self._is_rtl = False logical = self.get_line(0).get_pixel_extents()[1] ascent = pango.ASCENT(logical) decent = pango.DESCENT(logical) self._text_height = ascent + decent self._base_to_center = (self._text_height / 2) - decent self._update_smilies()
def add_text(self, buddy, text, status_message=False): """Display text on screen, with name and colors. buddy -- buddy object text -- string, what the buddy said status_message -- boolean False: show what buddy said True: show what buddy did hippo layout: .------------- rb ---------------. | +name_vbox+ +----msg_vbox----+ | | | | | | | | | nick: | | +--msg_hbox--+ | | | | | | | text | | | | +---------+ | +------------+ | | | | | | | | +--msg_hbox--+ | | | | | text | | | | | +------------+ | | | +----------------+ | `--------------------------------' """ if buddy: nick = buddy.props.nick color = buddy.props.color try: color_stroke_html, color_fill_html = color.split(',') except ValueError: color_stroke_html, color_fill_html = ('#000000', '#888888') # Select text color based on fill color: color_fill_rgba = Color(color_fill_html).get_rgba() color_fill_gray = (color_fill_rgba[0] + color_fill_rgba[1] + color_fill_rgba[2]) / 3 color_stroke = Color(color_stroke_html).get_int() color_fill = Color(color_fill_html).get_int() if color_fill_gray < 0.5: text_color = COLOR_WHITE.get_int() else: text_color = COLOR_BLACK.get_int() else: nick = '???' # XXX: should be '' but leave for debugging color_stroke = COLOR_BLACK.get_int() color_fill = COLOR_WHITE.get_int() text_color = COLOR_BLACK.get_int() color = '#000000,#FFFFFF' # Check for Right-To-Left languages: if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL: lang_rtl = True else: lang_rtl = False # Check if new message box or add text to previous: new_msg = True if self._last_msg_sender: if not status_message: if buddy == self._last_msg_sender: # Add text to previous message new_msg = False if not new_msg: rb = self._last_msg msg_vbox = rb.get_children()[1] msg_hbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_HORIZONTAL) msg_vbox.append(msg_hbox) else: rb = CanvasRoundBox(background_color=color_fill, border_color=color_stroke, padding=4) rb.props.border_color = color_stroke # Bug #3742 self._last_msg = rb self._last_msg_sender = buddy if not status_message: name = hippo.CanvasText(text=nick + ': ', color=text_color, font_desc=FONT_BOLD.get_pango_desc()) name_vbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_VERTICAL) name_vbox.append(name) rb.append(name_vbox) msg_vbox = hippo.CanvasBox(orientation=hippo.ORIENTATION_VERTICAL) rb.append(msg_vbox) msg_hbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_HORIZONTAL) msg_vbox.append(msg_hbox) if status_message: self._last_msg_sender = None if text: message = hippo.CanvasText(text=text, size_mode=hippo.CANVAS_SIZE_WRAP_WORD, color=text_color, font_desc=FONT_NORMAL.get_pango_desc(), xalign=hippo.ALIGNMENT_START) msg_hbox.append(message) # Order of boxes for RTL languages: if lang_rtl: msg_hbox.reverse() if new_msg: rb.reverse() if new_msg: box = hippo.CanvasBox(padding=2) box.append(rb) self.conversation.append(box)
def add_text(self, buddy, text, status_message=False): """Display text on screen, with name and colors. buddy -- buddy object or dict {nick: string, color: string} (The dict is for loading the chat log from the journal, when we don't have the buddy object any more.) text -- string, what the buddy said status_message -- boolean False: show what buddy said True: show what buddy did .------------- rb ---------------. | +name_vbox+ +----align-----+ | | | | | | | | | nick: | | +--message---+ | | | | | | | text | | | | +---------+ | +------------+ | | | +----------------+ | `--------------------------------' """ if not buddy: buddy = self.owner if type(buddy) is dict: # dict required for loading chat log from journal nick = buddy['nick'] color = buddy['color'] else: nick = buddy.props.nick color = buddy.props.color try: color_stroke_html, color_fill_html = color.split(',') except ValueError: color_stroke_html, color_fill_html = ('#000000', '#888888') # Select text color based on fill color: color_fill_rgba = style.Color(color_fill_html).get_rgba() color_fill_gray = (color_fill_rgba[0] + color_fill_rgba[1] + color_fill_rgba[2]) / 3 color_stroke = style.Color(color_stroke_html) color_fill = style.Color(color_fill_html) if color_fill_gray < 0.5: text_color = style.COLOR_WHITE else: text_color = style.COLOR_BLACK self._add_log(nick, color, text, status_message) # Check for Right-To-Left languages: if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL: lang_rtl = True else: lang_rtl = False # Check if new message box or add text to previous: new_msg = True if self._last_msg_sender: if not status_message: if buddy == self._last_msg_sender: # Add text to previous message new_msg = False if not new_msg: message = self._last_msg else: rb = RoundBox() screen_width = gtk.gdk.screen_width() # keep space to the scrollbar rb.set_size_request(screen_width - 50, -1) rb.background_color = color_fill rb.border_color = color_stroke self._last_msg_sender = buddy if not status_message: name = ColorLabel(text=nick + ': ', color=text_color) name_vbox = gtk.VBox() name_vbox.pack_start(name, False, False) rb.pack_start(name_vbox, False, False, padding=5) message = TextBox(text_color, color_fill, lang_rtl) vbox = gtk.VBox() vbox.pack_start(message, True, True, padding=5) rb.pack_start(vbox, True, True, padding=5) self._last_msg = message self._conversation.pack_start(rb, False, False, padding=2) if status_message: self._last_msg_sender = None message.add_text(text) self._conversation.show_all()
def add_text(self, buddy, text, status_message=False): """Display text on screen, with name and colors. buddy -- buddy object or dict {nick: string, color: string} (The dict is for loading the chat log from the journal, when we don't have the buddy object any more.) text -- string, what the buddy said status_message -- boolean False: show what buddy said True: show what buddy did .------------- rb ---------------. | +name_vbox+ +----align-----+ | | | | | | | | | nick: | | +--message---+ | | | | | | | text | | | | +---------+ | +------------+ | | | +----------------+ | `--------------------------------' """ if not buddy: buddy = self.owner if type(buddy) is dict: # dict required for loading chat log from journal nick = buddy['nick'] color = buddy['color'] else: nick = buddy.props.nick color = buddy.props.color try: color_stroke_html, color_fill_html = color.split(',') except ValueError: color_stroke_html, color_fill_html = ('#000000', '#888888') # Select text color based on fill color: color_fill_rgba = style.Color(color_fill_html).get_rgba() color_fill_gray = (color_fill_rgba[0] + color_fill_rgba[1] + color_fill_rgba[2]) / 3 color_stroke = style.Color(color_stroke_html) color_fill = style.Color(color_fill_html) if color_fill_gray < 0.5: text_color = style.COLOR_WHITE else: text_color = style.COLOR_BLACK self._add_log(nick, color, text, status_message) # Check for Right-To-Left languages: if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL: lang_rtl = True else: lang_rtl = False # Check if new message box or add text to previous: new_msg = True if self._last_msg_sender: if not status_message: if buddy == self._last_msg_sender: # Add text to previous message new_msg = False if not new_msg: message = self._last_msg else: rb = RoundBox() screen_width = gtk.gdk.screen_width() # keep space to the scrollbar rb.set_size_request(screen_width - 50, -1) rb.props.border_width = style.DEFAULT_PADDING rb.props.spacing = style.DEFAULT_SPACING rb.background_color = color_fill rb.border_color = color_stroke self._last_msg_sender = buddy if not status_message: name = ColorLabel(text=nick + ':', color=text_color) name_vbox = gtk.VBox() name_vbox.pack_start(name, False, False) rb.pack_start(name_vbox, False, False) message = TextBox(text_color, color_fill, lang_rtl) vbox = gtk.VBox() vbox.pack_start(message, True, True) rb.pack_start(vbox, True, True) self._last_msg = message self._conversation.pack_start(rb, False, False) if status_message: self._last_msg_sender = None message.add_text(text) self._conversation.show_all() """Here message.add_text(text) adding text in entry box add it to chatbox
def getRTL(self, message): '''check whether it's an right-to-left string''' if pango.find_base_dir(message, -1) == pango.DIRECTION_RTL: return '1' else: return '0'
def add_text(self, buddy, text, status_message=False): '''Display text on screen, with name and colors. buddy -- buddy object or dict {nick: string, color: string} (The dict is for loading the chat log from the journal, when we don't have the buddy object any more.) text -- string, what the buddy said status_message -- boolean False: show what buddy said True: show what buddy did .----- rb ------------. | +----align-------+ | | | +--message---+ | | | | | nick: | | | | | | text 1 | | | | | | text 2 | | | | | +------------+ | | | +----------------+ | `----------------- +--' \| The color scheme for owner messages is: nick in darker of stroke and fill colors background in lighter of stroke and fill colors text in black The color scheme for buddy messages is: nick in darker of stroke and fill colors background in light gray text in black rb has a tail on the right for owner messages and the left for buddy messages. ''' if not buddy: buddy = self._owner if type(buddy) is dict: # dict required for loading chat log from journal nick = buddy['nick'] color = buddy['color'] elif buddy is None: nick = 'unknown' color = '#000000,#808080' else: nick = buddy.props.nick color = buddy.props.color try: color_stroke_html, color_fill_html = color.split(',') except ValueError: color_stroke_html, color_fill_html = ('#000000', '#888888') lighter = lighter_color(color.split(',')) darker = 1 - lighter if len(text) > 3 and text[0:4] == '/me ': me_message = True else: me_message = False if status_message or me_message: text_color = style.COLOR_WHITE nick_color = style.COLOR_WHITE color_fill = style.Color('#808080') highlight_fill = style.COLOR_WHITE tail = None else: highlight_fill = style.COLOR_BUTTON_GREY text_color = style.COLOR_BLACK if darker == 1: color_fill = style.Color(color_stroke_html) if is_low_contrast(color.split(',')): nick_color = text_color else: nick_color = style.Color(color_fill_html) else: color_fill = style.Color(color_fill_html) if is_low_contrast(color.split(',')): nick_color = text_color else: nick_color = style.Color(color_stroke_html) if nick == profile.get_nick_name(): tail = 'right' else: tail = 'left' color_stroke = None self._add_log(nick, color, text, status_message) # Check for Right-To-Left languages: if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL: lang_rtl = True else: lang_rtl = False # Check if new message box or add text to previous: new_msg = True if self._last_msg_sender and buddy == self._last_msg_sender: # Add text to previous message if not (me_message or status_message): new_msg = False if not new_msg: message = self._last_msg message.add_text(text) else: rb = RoundBox() rb.background_color = color_fill rb.border_color = color_stroke rb.tail = tail self._rb_list.append(rb) grid_internal = gtk.VBox() grid_internal.set_size_request( gtk.gdk.screen_width() - style.GRID_CELL_SIZE, style.GRID_CELL_SIZE) # -1) self._grid_list.append(grid_internal) row = 0 if status_message: nick = None elif me_message: text = text[4:] message = TextBox(self, nick_color, text_color, color_fill, highlight_fill, lang_rtl, nick, text) self._message_list.append(message) self._last_msg_sender = buddy self._last_msg = message grid_internal.pack_start(message, expand=False, padding=0) row += 1 align = gtk.Alignment(0.0, 0.0, 1.0, 1.0) if rb.tail is None: bottom_padding = style.zoom(7) else: bottom_padding = style.zoom(40) align.set_padding(style.zoom(7), bottom_padding, style.zoom(30), style.zoom(30)) align.add(grid_internal) grid_internal.show() rb.pack_start(align, True, True, 0) align.show() self._conversation.pack_start(rb, expand=False, padding=style.DEFAULT_PADDING) rb.show() self._row_counter += 1 message.show() if status_message: self._last_msg_sender = None
def add_text(self, buddy, text, status_message=False): """Display text on screen, with name and colors. buddy -- buddy object text -- string, what the buddy said status_message -- boolean False: show what buddy said True: show what buddy did hippo layout: .------------- rb ---------------. | +name_vbox+ +----msg_vbox----+ | | | | | | | | | nick: | | +--msg_hbox--+ | | | | | | | text | | | | +---------+ | +------------+ | | | | | | | | +--msg_hbox--+ | | | | | text | | | | | +------------+ | | | +----------------+ | `--------------------------------' """ if buddy: nick = buddy.props.nick color = buddy.props.color try: color_stroke_html, color_fill_html = color.split(',') except ValueError: color_stroke_html, color_fill_html = ('#000000', '#888888') # Select text color based on fill color: color_fill_rgba = Color(color_fill_html).get_rgba() color_fill_gray = (color_fill_rgba[0] + color_fill_rgba[1] + color_fill_rgba[2])/3 color_stroke = Color(color_stroke_html).get_int() color_fill = Color(color_fill_html).get_int() if color_fill_gray < 0.5: text_color = COLOR_WHITE.get_int() else: text_color = COLOR_BLACK.get_int() else: nick = '???' # XXX: should be '' but leave for debugging color_stroke = COLOR_BLACK.get_int() color_fill = COLOR_WHITE.get_int() text_color = COLOR_BLACK.get_int() color = '#000000,#FFFFFF' # Check for Right-To-Left languages: if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL: lang_rtl = True else: lang_rtl = False # Check if new message box or add text to previous: new_msg = True if self._last_msg_sender: if not status_message: if buddy == self._last_msg_sender: # Add text to previous message new_msg = False if not new_msg: rb = self._last_msg msg_vbox = rb.get_children()[1] msg_hbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_HORIZONTAL) msg_vbox.append(msg_hbox) else: rb = CanvasRoundBox(background_color=color_fill, border_color=color_stroke, padding=4) rb.props.border_color = color_stroke # Bug #3742 self._last_msg = rb self._last_msg_sender = buddy if not status_message: name = hippo.CanvasText(text=nick+': ', color=text_color, font_desc=FONT_BOLD.get_pango_desc()) name_vbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_VERTICAL) name_vbox.append(name) rb.append(name_vbox) msg_vbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_VERTICAL) rb.append(msg_vbox) msg_hbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_HORIZONTAL) msg_vbox.append(msg_hbox) if status_message: self._last_msg_sender = None if text: message = hippo.CanvasText( text=text, size_mode=hippo.CANVAS_SIZE_WRAP_WORD, color=text_color, font_desc=FONT_NORMAL.get_pango_desc(), xalign=hippo.ALIGNMENT_START) msg_hbox.append(message) # Order of boxes for RTL languages: if lang_rtl: msg_hbox.reverse() if new_msg: rb.reverse() if new_msg: box = hippo.CanvasBox(padding=2) box.append(rb) self.conversation.append(box)
def add_text(self, buddy, text, status_message=False): if not buddy: buddy = self.owner if buddy == "Computer": nick = "Computer" color = '#000000,#FFF8DC' else: if type(buddy) is dict: # dict required for loading chat log from journal nick = buddy['nick'] color = buddy['color'] else: nick = buddy.props.nick color = buddy.props.color try: color_stroke_html, color_fill_html = color.split(',') except ValueError: color_stroke_html, color_fill_html = ('#000000', '#888888') # Select text color based on fill color: color_fill_rgba = style.Color(color_fill_html).get_rgba() color_fill_gray = (color_fill_rgba[0] + color_fill_rgba[1] + color_fill_rgba[2]) / 3 color_stroke = style.Color(color_stroke_html) color_fill = style.Color(color_fill_html) if color_fill_gray < 0.5: text_color = style.COLOR_WHITE else: text_color = style.COLOR_BLACK self._add_log(nick, text, status_message) # Check for Right-To-Left languages: if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL: lang_rtl = True else: lang_rtl = False # Check if new message box or add text to previous: new_msg = True if self._last_msg_sender: if not status_message: if buddy == self._last_msg_sender: # Add text to previous message new_msg = True if not new_msg: message = self._last_msg else: rb = RoundBox() screen_width = gtk.gdk.screen_width() # keep space to the scrollbar rb.set_size_request(screen_width - 50, -1) rb.props.border_width = style.DEFAULT_PADDING rb.props.spacing = style.DEFAULT_SPACING rb.background_color = color_fill rb.border_color = color_stroke self._last_msg_sender = buddy if not status_message: name = ColorLabel(text=nick + ':', color=text_color) name_vbox = gtk.VBox() name_vbox.pack_start(name, False, False) rb.pack_start(name_vbox, False, False) message = TextBox(text_color, color_fill, lang_rtl) vbox = gtk.VBox() vbox.pack_start(message, True, True) rb.pack_start(vbox, True, True) self._last_msg = message self._conversation.pack_start(rb, False, False) if status_message: self._last_msg_sender = None message.add_text(text) self._conversation.show_all()
def add_text(self, buddy, text, status_message=False): """Display text on screen, with name and colors. buddy -- buddy object or dict {nick: string, color: string} (The dict is for loading the chat log from the journal, when we don't have the buddy object any more.) text -- string, what the buddy said status_message -- boolean False: show what buddy said True: show what buddy did hippo layout: .------------- rb ---------------. | +name_vbox+ +----msg_vbox----+ | | | | | | | | | nick: | | +--msg_hbox--+ | | | | | | | text | | | | +---------+ | +------------+ | | | | | | | | +--msg_hbox--+ | | | | | text | url | | | | | +------------+ | | | +----------------+ | `--------------------------------' """ if not buddy: buddy = self.owner if type(buddy) is dict: # dict required for loading chat log from journal nick = buddy['nick'] color = buddy['color'] else: nick = buddy.props.nick color = buddy.props.color try: color_stroke_html, color_fill_html = color.split(',') except ValueError: color_stroke_html, color_fill_html = ('#000000', '#888888') # Select text color based on fill color: color_fill_rgba = Color(color_fill_html).get_rgba() color_fill_gray = (color_fill_rgba[0] + color_fill_rgba[1] + color_fill_rgba[2]) / 3 color_stroke = Color(color_stroke_html).get_int() color_fill = Color(color_fill_html).get_int() if color_fill_gray < 0.5: text_color = COLOR_WHITE.get_int() else: text_color = COLOR_BLACK.get_int() self._add_log(nick, color, text, status_message) # Check for Right-To-Left languages: if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL: lang_rtl = True else: lang_rtl = False # Check if new message box or add text to previous: new_msg = True if self._last_msg_sender: if not status_message: if buddy == self._last_msg_sender: # Add text to previous message new_msg = False if not new_msg: rb = self._last_msg msg_vbox = rb.get_children()[1] msg_hbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_HORIZONTAL) msg_vbox.append(msg_hbox) else: rb = CanvasRoundBox(background_color=color_fill, border_color=color_stroke, padding=4) rb.props.border_color = color_stroke # Bug #3742 self._last_msg = rb self._last_msg_sender = buddy if not status_message: name = hippo.CanvasText(text=nick + ': ', color=text_color) name_vbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_VERTICAL) name_vbox.append(name) rb.append(name_vbox) msg_vbox = hippo.CanvasBox(orientation=hippo.ORIENTATION_VERTICAL) rb.append(msg_vbox) msg_hbox = hippo.CanvasBox( orientation=hippo.ORIENTATION_HORIZONTAL) msg_vbox.append(msg_hbox) if status_message: self._last_msg_sender = None match = URL_REGEXP.search(text) while match: # there is a URL in the text starttext = text[:match.start()] if starttext: message = hippo.CanvasText( text=starttext, size_mode=hippo.CANVAS_SIZE_WRAP_WORD, color=text_color, xalign=hippo.ALIGNMENT_START) msg_hbox.append(message) url = text[match.start():match.end()] message = CanvasLink(text=url, color=text_color) attrs = pango.AttrList() attrs.insert(pango.AttrUnderline(pango.UNDERLINE_SINGLE, 0, 32767)) message.set_property("attributes", attrs) message.connect('activated', self._link_activated_cb) # call interior magic which should mean just: # CanvasInvoker().parent = message CanvasInvoker(message) msg_hbox.append(message) text = text[match.end():] match = URL_REGEXP.search(text) if text: message = hippo.CanvasText(text=text, size_mode=hippo.CANVAS_SIZE_WRAP_WORD, color=text_color, xalign=hippo.ALIGNMENT_START) msg_hbox.append(message) # Order of boxes for RTL languages: if lang_rtl: msg_hbox.reverse() if new_msg: rb.reverse() if new_msg: box = hippo.CanvasBox(padding=2) box.append(rb) self._conversation.append(box)