Private
Public Access
1
0
Files
Kordophone/src/transcript/transcript-container-view.vala

58 lines
1.8 KiB
Vala
Raw Normal View History

2025-05-02 15:09:12 -07:00
using Gtk;
using Adw;
2025-05-03 22:47:56 -07:00
class TranscriptContainerView : Adw.Bin {
public TranscriptView transcript_view;
2025-05-02 15:09:12 -07:00
public Entry message_entry;
public signal void on_send(string message);
private Box container;
private Button send_button;
2025-05-03 22:47:56 -07:00
public TranscriptContainerView () {
2025-05-02 15:09:12 -07:00
container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
set_child (container);
// Create message list view
2025-05-03 22:47:56 -07:00
transcript_view = new TranscriptView();
transcript_view.set_vexpand(true);
container.append(transcript_view);
2025-05-02 15:09:12 -07:00
// Create bottom box for input
var input_box = new Box(Orientation.HORIZONTAL, 6);
input_box.add_css_class("message-input-box");
input_box.set_valign(Align.END);
input_box.set_spacing(6);
container.append(input_box);
// Create message entry
message_entry = new Entry();
message_entry.add_css_class("message-input-entry");
message_entry.set_placeholder_text("Type a message...");
message_entry.set_hexpand(true);
message_entry.changed.connect(on_text_changed);
message_entry.activate.connect(on_request_send);
input_box.append(message_entry);
// Create send button
send_button = new Button();
send_button.set_label("Send");
send_button.set_sensitive(false);
send_button.add_css_class("suggested-action");
send_button.clicked.connect(on_request_send);
input_box.append(send_button);
}
private void on_text_changed() {
send_button.set_sensitive(message_entry.text.length > 0);
}
private void on_request_send() {
if (message_entry.text.length > 0) {
on_send(message_entry.text);
message_entry.text = "";
}
}
}