From 68ebe0d9adff8ee2868851a2d96b8be1c6f7f1b6 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 26 Apr 2006 16:52:27 -0400 Subject: [PATCH] Fix rich text in the chat --- chat/chat.py | 5 ++--- chat/richtext.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/chat/chat.py b/chat/chat.py index 5b0a99ce..e978a2a4 100755 --- a/chat/chat.py +++ b/chat/chat.py @@ -52,11 +52,10 @@ class Chat(activity.Activity): chat_vbox.pack_start(sw) sw.show() - rich_buf = richtext.RichTextBuffer() chat_view_sw = gtk.ScrolledWindow() chat_view_sw.set_shadow_type(gtk.SHADOW_IN) chat_view_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self._editor = richtext.RichTextView(rich_buf) + self._editor = richtext.RichTextView() self._editor.connect("key-press-event", self.__key_press_event_cb) self._editor.set_size_request(-1, 50) chat_view_sw.add(self._editor) @@ -65,7 +64,7 @@ class Chat(activity.Activity): chat_vbox.pack_start(chat_view_sw, False) chat_view_sw.show() - return chat_vbox, rich_buf + return chat_vbox, self._editor.get_buffer() def _ui_setup(self, base): vbox = gtk.VBox(False, 6) diff --git a/chat/richtext.py b/chat/richtext.py index 88d40357..0ac70b16 100644 --- a/chat/richtext.py +++ b/chat/richtext.py @@ -14,8 +14,8 @@ class RichTextView(gtk.TextView): ([gobject.TYPE_STRING])) } - def __init__(self, rich_buf = None): - gtk.TextView.__init__(self, rich_buf) + def __init__(self): + gtk.TextView.__init__(self, RichTextBuffer()) self.connect("motion-notify-event", self.__motion_notify_cb) self.connect("button-press-event", self.__button_press_cb) self.__hover_link = False @@ -343,8 +343,13 @@ if __name__ == "__main__": vbox = gtk.VBox() - rich_buf = RichTextBuffer() + view = RichTextView() + view.connect("link-clicked", link_clicked) + vbox.pack_start(view) + view.show() + rich_buf = view.get_buffer() + xml_string = "" xml_string += "Testone\n" @@ -355,11 +360,6 @@ if __name__ == "__main__": RichTextSerializer().deserialize(xml_string, rich_buf) - view = RichTextView(rich_buf) - view.connect("link-clicked", link_clicked) - vbox.pack_start(view) - view.show() - toolbar = RichTextToolbar(rich_buf) vbox.pack_start(toolbar, False) toolbar.show()