2025-04-28 17:29:32 -07:00
|
|
|
using Adw;
|
|
|
|
|
using Gtk;
|
|
|
|
|
|
|
|
|
|
public class MainWindow : Adw.ApplicationWindow
|
|
|
|
|
{
|
2025-04-30 19:50:36 -07:00
|
|
|
private ConversationListView conversation_list_view;
|
2025-05-02 15:09:12 -07:00
|
|
|
private TranscriptView transcript_view;
|
2025-04-30 19:50:36 -07:00
|
|
|
|
2025-04-28 17:29:32 -07:00
|
|
|
public MainWindow () {
|
|
|
|
|
Object (title: "Kordophone");
|
|
|
|
|
|
|
|
|
|
var split_view = new NavigationSplitView ();
|
|
|
|
|
split_view.set_min_sidebar_width (400);
|
|
|
|
|
set_content (split_view);
|
|
|
|
|
|
2025-04-30 19:50:36 -07:00
|
|
|
conversation_list_view = new ConversationListView ();
|
|
|
|
|
conversation_list_view.conversation_selected.connect (conversation_selected);
|
|
|
|
|
|
|
|
|
|
var conversation_list_page = new NavigationPage (conversation_list_view, "Conversations");
|
2025-04-28 17:29:32 -07:00
|
|
|
split_view.sidebar = conversation_list_page;
|
2025-04-30 15:58:47 -07:00
|
|
|
|
2025-05-02 15:09:12 -07:00
|
|
|
transcript_view = new TranscriptView ();
|
|
|
|
|
transcript_view.on_send.connect (on_transcript_send);
|
|
|
|
|
|
|
|
|
|
var transcript_page = new NavigationPage (transcript_view, "Transcript");
|
|
|
|
|
split_view.content = transcript_page;
|
2025-04-28 17:29:32 -07:00
|
|
|
}
|
2025-04-30 19:50:36 -07:00
|
|
|
|
|
|
|
|
private void conversation_selected(string? conversation_guid) {
|
|
|
|
|
if (conversation_guid == null) {
|
2025-05-02 15:09:12 -07:00
|
|
|
transcript_view.message_list.model = null;
|
2025-04-30 19:50:36 -07:00
|
|
|
} else {
|
2025-05-02 15:09:12 -07:00
|
|
|
transcript_view.message_list.model = new MessageListModel (conversation_guid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void on_transcript_send(string message) {
|
|
|
|
|
if (transcript_view.message_list.model == null) {
|
|
|
|
|
GLib.warning("No conversation selected");
|
|
|
|
|
return;
|
2025-04-30 19:50:36 -07:00
|
|
|
}
|
2025-05-02 15:09:12 -07:00
|
|
|
|
|
|
|
|
var selected_conversation = transcript_view.message_list.model.conversation_guid;
|
|
|
|
|
if (selected_conversation == null) {
|
|
|
|
|
GLib.warning("No conversation selected");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Repository.get_instance().send_message(selected_conversation, message);
|
2025-04-30 19:50:36 -07:00
|
|
|
}
|
2025-04-28 17:29:32 -07:00
|
|
|
}
|