public class Conversation { private Gtk.Notebook conversations; private Gtk.Widget widget; private Gtk.TextView content; private Gtk.Entry entry; 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) { pack_start(new Gtk.Label(label), false, true, 0); Gtk.Button closeButton = new Gtk.Button(); Gdk.Pixbuf closeImage = render_icon(Gtk.STOCK_CLOSE, (Gtk.IconSize)(-1), null); closeButton.image = new Gtk.Image.from_pixbuf(closeImage.scale_simple(16, 16, Gdk.InterpType.BILINEAR)); closeButton.height_request = 20; closeButton.relief = Gtk.ReliefStyle.NONE; pack_end(closeButton, false, false, 0); show_all(); } } public Conversation(Gtk.Notebook conversations0, string jid0, string? display_name0, bool explicit = true) { conversations = conversations0; jid = jid0; if(display_name0 != null) display_name = display_name0; else display_name = jid; Gtk.Builder builder = new Gtk.Builder(); try { builder.add_objects_from_file("ephraim.glade", {"Conversation"}); } catch(Error e) { } widget = builder.get_object("Conversation") as Gtk.Widget; 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); int page = conversations.append_page(widget, new TabLabel(display_name)); conversations.set_tab_reorderable(widget, true); if(explicit) conversations.page = page; } ~Conversation() { conversations.remove(widget); } public void chat_message(string from, string type, string message) { if(type != "chat") return; string str = from + ": " + message; if(content.buffer.text.length != 0) str = "\n" + str; content.buffer.text += str; } }