diff --git a/src/application/main-window.vala b/src/application/main-window.vala index 3420fd5..685c775 100644 --- a/src/application/main-window.vala +++ b/src/application/main-window.vala @@ -4,7 +4,7 @@ using Gtk; public class MainWindow : Adw.ApplicationWindow { private ConversationListView conversation_list_view; - private MessageListView message_list_view; + private TranscriptView transcript_view; public MainWindow () { Object (title: "Kordophone"); @@ -19,16 +19,33 @@ public class MainWindow : Adw.ApplicationWindow var conversation_list_page = new NavigationPage (conversation_list_view, "Conversations"); split_view.sidebar = conversation_list_page; - message_list_view = new MessageListView (new MessageListModel ("123")); - var message_list_page = new NavigationPage (message_list_view, "Messages"); - split_view.content = message_list_page; + 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; } private void conversation_selected(string? conversation_guid) { if (conversation_guid == null) { - message_list_view.model = null; + transcript_view.message_list.model = null; } else { - message_list_view.model = new MessageListModel (conversation_guid); + 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; + } + + 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); + } } \ No newline at end of file diff --git a/src/conversation-list/conversation-list-model.vala b/src/conversation-list/conversation-list-model.vala index 18fc2fa..643f971 100644 --- a/src/conversation-list/conversation-list-model.vala +++ b/src/conversation-list/conversation-list-model.vala @@ -16,6 +16,7 @@ public class ConversationListModel : Object, ListModel }); Repository.get_instance().conversations_updated.connect(load_conversations); + Repository.get_instance().messages_updated.connect(load_conversations); } public void load_conversations() { diff --git a/src/meson.build b/src/meson.build index bfede65..f143b9d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -31,6 +31,8 @@ sources = [ 'models/conversation.vala', 'models/message.vala', + + 'transcript-view/transcript-view.vala', ] executable('kordophone', diff --git a/src/message-list/message-layout.vala b/src/message-list/message-layout.vala index e70a3fe..85e57fd 100644 --- a/src/message-list/message-layout.vala +++ b/src/message-list/message-layout.vala @@ -14,7 +14,7 @@ private struct MessageLayoutConstants { tail_curve_offset = 2.5f / scale_factor; tail_side_offset = 0.0f / scale_factor; tail_bottom_padding = 4.0f / scale_factor; - corner_radius = 32.0f / scale_factor; + corner_radius = 24.0f / scale_factor; text_padding = 18.0f / scale_factor; } } diff --git a/src/message-list/message-list-model.vala b/src/message-list/message-list-model.vala index 3bfd75e..0f8b05a 100644 --- a/src/message-list/message-list-model.vala +++ b/src/message-list/message-list-model.vala @@ -9,7 +9,7 @@ public class MessageListModel : Object, ListModel owned get { return _messages.read_only_view; } } - private string _conversation_guid; + public string conversation_guid { get; private set; } private SortedSet _messages; public MessageListModel(string conversation_guid) { @@ -19,12 +19,12 @@ public class MessageListModel : Object, ListModel }); Repository.get_instance().messages_updated.connect(got_messages_updated); - _conversation_guid = conversation_guid; + this.conversation_guid = conversation_guid; } public void load_messages() { try { - Message[] messages = Repository.get_instance().get_messages(_conversation_guid); + Message[] messages = Repository.get_instance().get_messages(conversation_guid); // Clear existing set uint old_count = _messages.size; @@ -56,7 +56,7 @@ public class MessageListModel : Object, ListModel } private void got_messages_updated(string conversation_guid) { - if (conversation_guid == _conversation_guid) { + if (conversation_guid == this.conversation_guid) { load_messages(); } } diff --git a/src/resources/style.css b/src/resources/style.css index 20b65e0..f3cadf4 100644 --- a/src/resources/style.css +++ b/src/resources/style.css @@ -17,4 +17,15 @@ .message-drawing-area { color: darker(@accent_bg_color); +} + +.message-input-box { + margin-bottom: 14px; + margin-top: 14px; + margin-left: 14px; + margin-right: 14px; +} + +.message-input-entry { + font-size: 1.1rem; } \ No newline at end of file diff --git a/src/service/interface/dbusservice.vala b/src/service/interface/dbusservice.vala index 0dbd5af..ded23fd 100644 --- a/src/service/interface/dbusservice.vala +++ b/src/service/interface/dbusservice.vala @@ -32,6 +32,9 @@ namespace DBusService { [DBus (name = "GetConversations")] public abstract GLib.HashTable[] get_conversations() throws DBusError, IOError; + [DBus (name = "SyncConversationList")] + public abstract void sync_conversation_list() throws DBusError, IOError; + [DBus (name = "SyncAllConversations")] public abstract void sync_all_conversations() throws DBusError, IOError; @@ -41,9 +44,15 @@ namespace DBusService { [DBus (name = "ConversationsUpdated")] public signal void conversations_updated(); + [DBus (name = "DeleteAllConversations")] + public abstract void delete_all_conversations() throws DBusError, IOError; + [DBus (name = "GetMessages")] public abstract GLib.HashTable[] get_messages(string conversation_id, string last_message_id) throws DBusError, IOError; + [DBus (name = "SendMessage")] + public abstract string send_message(string conversation_id, string text) throws DBusError, IOError; + [DBus (name = "MessagesUpdated")] public signal void messages_updated(string conversation_id); } diff --git a/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml index bbe5263..01fb1c3 100644 --- a/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml +++ b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml @@ -24,6 +24,11 @@ + + + + @@ -40,6 +45,11 @@ value="Emitted when the list of conversations is updated."/> + + + + @@ -48,6 +58,15 @@ + + + + + + + + 0); + } + + private void on_request_send() { + if (message_entry.text.length > 0) { + on_send(message_entry.text); + message_entry.text = ""; + } + } +} +