From fe332740f7c0be59d4ede7097e5bd1eabbf40e39 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 25 Jun 2010 06:14:12 +0200 Subject: Chatting works now --- src/gui/Conversation.vala | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/gui/Conversation.vala') diff --git a/src/gui/Conversation.vala b/src/gui/Conversation.vala index 321fba9..629461e 100644 --- a/src/gui/Conversation.vala +++ b/src/gui/Conversation.vala @@ -1,9 +1,14 @@ public class Conversation { private Gtk.Notebook conversations; private Gtk.Widget widget; + private Gtk.TextView content; + private Gtk.Entry entry; + private string me; private string jid; private string display_name; + + public signal void send_message(string type, string message); private class TabLabel : Gtk.HBox { public TabLabel(string label) { @@ -21,8 +26,9 @@ public class Conversation { } } - public Conversation(Gtk.Notebook conversations0, string jid0, string? display_name0) { + public Conversation(Gtk.Notebook conversations0, string me0, string jid0, string? display_name0) { conversations = conversations0; + me = me0; jid = jid0; if(display_name0 != null) @@ -38,8 +44,15 @@ public class Conversation { } widget = builder.get_object("Conversation") as Gtk.Widget; - unowned Gtk.Label title = builder.get_object("ConversationTitle") as Gtk.Label; + content = builder.get_object("ConversationContent") as Gtk.TextView; + entry = builder.get_object("ConversationEntry") as Gtk.Entry; + + entry.activate.connect((widget) => { + send_message("chat", entry.text); + entry.text = ""; + }); + unowned Gtk.Label title = builder.get_object("ConversationTitle") as Gtk.Label; title.set_text("Conversation with " + display_name); conversations.append_page(widget, new TabLabel(display_name)); @@ -48,4 +61,18 @@ public class Conversation { ~Conversation() { conversations.remove(widget); } + + public void sent_message(string type, string message) { + if(type != "chat") + return; + + content.buffer.text += me + ": " + message + "\n"; + } + + public void receive_message(string type, string message) { + if(type != "chat") + return; + + content.buffer.text += display_name + ": " + message + "\n"; + } } -- cgit v1.2.3