diff options
author | Marco Pesenti Gritti <mpg@redhat.com> | 2006-04-26 20:52:27 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <mpg@redhat.com> | 2006-04-26 20:52:27 (GMT) |
commit | 68ebe0d9adff8ee2868851a2d96b8be1c6f7f1b6 (patch) | |
tree | f08859c1865c160e82c0d74982e9c59d1b87369e /chat | |
parent | 5078a974790613188082122c7d7221cbc3fdcdef (diff) |
Fix rich text in the chat
Diffstat (limited to 'chat')
-rwxr-xr-x | chat/chat.py | 5 | ||||
-rw-r--r-- | chat/richtext.py | 16 |
2 files changed, 10 insertions, 11 deletions
diff --git a/chat/chat.py b/chat/chat.py index 5b0a99c..e978a2a 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 88d4035..0ac70b1 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 = "<richtext>" xml_string += "<bold><italic>Test</italic>one</bold>\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() |