Rework UI chat. Simple but somewhat nicer.

This commit is contained in:
Marco Pesenti Gritti 2006-04-24 13:50:39 -04:00
parent f9e2a73b9a
commit 135ceef80a

View File

@ -122,18 +122,17 @@ class ChatActivity(activity.Activity):
(self._nick, self._realname) = self._get_name() (self._nick, self._realname) = self._get_name()
def _ui_setup(self, plug): def _create_chat(self):
hbox = gtk.HBox(False, 6)
chat_vbox = gtk.VBox() chat_vbox = gtk.VBox()
hbox.pack_start(chat_vbox) chat_vbox.set_spacing(6)
chat_vbox.show()
self._chat_label = gtk.Label() self._chat_label = gtk.Label()
chat_vbox.pack_start(self._chat_label, False) chat_vbox.pack_start(self._chat_label, False)
self._chat_label.show() # Do we actually need this label?
# self._chat_label.show()
sw = gtk.ScrolledWindow() sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_IN)
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
self._chat_view = gtk.TextView() self._chat_view = gtk.TextView()
sw.add(self._chat_view) sw.add(self._chat_view)
@ -143,31 +142,41 @@ class ChatActivity(activity.Activity):
rich_buf = richtext.RichTextBuffer() 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_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) chat_view_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self._editor = gtk.TextView(rich_buf) self._editor = gtk.TextView(rich_buf)
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, 100) self._editor.set_size_request(-1, 50)
chat_view_sw.add(self._editor) chat_view_sw.add(self._editor)
self._editor.show() self._editor.show()
toolbar = richtext.RichTextToolbar(rich_buf) chat_vbox.pack_start(chat_view_sw, False)
chat_vbox.pack_start(toolbar, False);
toolbar.show()
chat_vbox.pack_start(chat_view_sw, False);
chat_view_sw.show() chat_view_sw.show()
return chat_vbox, rich_buf
def _create_sidebar(self):
vbox = gtk.VBox(False, 6)
label = gtk.Label("Who's around:")
label.set_alignment(0.0, 0.5)
vbox.pack_start(label, False)
label.show()
self._buddy_list_model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) self._buddy_list_model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
sw = gtk.ScrolledWindow() sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_IN)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self._buddy_list_view = gtk.TreeView(self._buddy_list_model) self._buddy_list_view = gtk.TreeView(self._buddy_list_model)
self._buddy_list_view.set_headers_visible(False)
self._buddy_list_view.connect("cursor-changed", self._on_buddyList_buddy_selected) self._buddy_list_view.connect("cursor-changed", self._on_buddyList_buddy_selected)
self._buddy_list_view.connect("row-activated", self._on_buddyList_buddy_double_clicked) self._buddy_list_view.connect("row-activated", self._on_buddyList_buddy_double_clicked)
sw.set_size_request(150, -1)
sw.set_size_request(120, -1)
sw.add(self._buddy_list_view) sw.add(self._buddy_list_view)
self._buddy_list_view.show() self._buddy_list_view.show()
hbox.pack_start(sw, False)
sw.show()
renderer = gtk.CellRendererText() renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn("", renderer, text=0) column = gtk.TreeViewColumn("", renderer, text=0)
@ -176,13 +185,49 @@ class ChatActivity(activity.Activity):
column.set_expand(True); column.set_expand(True);
self._buddy_list_view.append_column(column) self._buddy_list_view.append_column(column)
vbox.pack_start(sw)
sw.show()
button_box = gtk.VButtonBox()
button_box.set_border_width(18)
talk_alone_button = gtk.Button("Talk alone")
button_box.pack_start(talk_alone_button)
talk_alone_button.show()
vbox.pack_start(button_box, False)
button_box.show()
return vbox
def _ui_setup(self, plug):
vbox = gtk.VBox(False, 6)
vbox.set_border_width(12)
hbox = gtk.HBox(False, 12)
[chat, rich_buf] = self._create_chat()
hbox.pack_start(chat)
chat.show()
sidebar = self._create_sidebar()
hbox.pack_start(sidebar, False)
sidebar.show()
vbox.pack_start(hbox)
hbox.show()
toolbar = richtext.RichTextToolbar(rich_buf)
vbox.pack_start(toolbar, False);
toolbar.show()
self._group_chat = GroupChat(self, self._chat_view, self._chat_label) self._group_chat = GroupChat(self, self._chat_view, self._chat_label)
aniter = self._buddy_list_model.append(None) aniter = self._buddy_list_model.append(None)
self._buddy_list_model.set(aniter, 0, "Group", 1, None) self._buddy_list_model.set(aniter, 0, "Group", 1, None)
self._group_chat.activate() self._group_chat.activate()
plug.add(hbox)
hbox.show() plug.add(vbox)
vbox.show()
def __key_press_event_cb(self, text_view, event): def __key_press_event_cb(self, text_view, event):
if event.keyval == gtk.keysyms.Return: if event.keyval == gtk.keysyms.Return:
@ -217,7 +262,7 @@ class ChatActivity(activity.Activity):
self.activity_set_tab_text(self._act_name) self.activity_set_tab_text(self._act_name)
self._plug = self.activity_get_gtk_plug() self._plug = self.activity_get_gtk_plug()
self._ui_setup(self._plug) self._ui_setup(self._plug)
self._plug.show_all() self._plug.show()
self._start() self._start()
def activity_on_disconnected_from_shell(self): def activity_on_disconnected_from_shell(self):