Fix rich text in the chat

This commit is contained in:
Marco Pesenti Gritti 2006-04-26 16:52:27 -04:00
parent 5078a97479
commit 68ebe0d9ad
2 changed files with 10 additions and 11 deletions

View File

@ -52,11 +52,10 @@ class Chat(activity.Activity):
chat_vbox.pack_start(sw) chat_vbox.pack_start(sw)
sw.show() sw.show()
rich_buf = richtext.RichTextBuffer()
chat_view_sw = gtk.ScrolledWindow() chat_view_sw = gtk.ScrolledWindow()
chat_view_sw.set_shadow_type(gtk.SHADOW_IN) chat_view_sw.set_shadow_type(gtk.SHADOW_IN)
chat_view_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 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.connect("key-press-event", self.__key_press_event_cb)
self._editor.set_size_request(-1, 50) self._editor.set_size_request(-1, 50)
chat_view_sw.add(self._editor) chat_view_sw.add(self._editor)
@ -65,7 +64,7 @@ class Chat(activity.Activity):
chat_vbox.pack_start(chat_view_sw, False) chat_vbox.pack_start(chat_view_sw, False)
chat_view_sw.show() chat_view_sw.show()
return chat_vbox, rich_buf return chat_vbox, self._editor.get_buffer()
def _ui_setup(self, base): def _ui_setup(self, base):
vbox = gtk.VBox(False, 6) vbox = gtk.VBox(False, 6)

View File

@ -14,8 +14,8 @@ class RichTextView(gtk.TextView):
([gobject.TYPE_STRING])) ([gobject.TYPE_STRING]))
} }
def __init__(self, rich_buf = None): def __init__(self):
gtk.TextView.__init__(self, rich_buf) gtk.TextView.__init__(self, RichTextBuffer())
self.connect("motion-notify-event", self.__motion_notify_cb) self.connect("motion-notify-event", self.__motion_notify_cb)
self.connect("button-press-event", self.__button_press_cb) self.connect("button-press-event", self.__button_press_cb)
self.__hover_link = False self.__hover_link = False
@ -343,7 +343,12 @@ if __name__ == "__main__":
vbox = gtk.VBox() 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 = "<richtext>"
@ -355,11 +360,6 @@ if __name__ == "__main__":
RichTextSerializer().deserialize(xml_string, rich_buf) 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) toolbar = RichTextToolbar(rich_buf)
vbox.pack_start(toolbar, False) vbox.pack_start(toolbar, False)
toolbar.show() toolbar.show()