reorg: message-list -> transcript
This commit is contained in:
@@ -4,7 +4,7 @@ using Gtk;
|
|||||||
public class MainWindow : Adw.ApplicationWindow
|
public class MainWindow : Adw.ApplicationWindow
|
||||||
{
|
{
|
||||||
private ConversationListView conversation_list_view;
|
private ConversationListView conversation_list_view;
|
||||||
private TranscriptView transcript_view;
|
private TranscriptContainerView transcript_container_view;
|
||||||
|
|
||||||
public MainWindow () {
|
public MainWindow () {
|
||||||
Object (title: "Kordophone");
|
Object (title: "Kordophone");
|
||||||
@@ -19,10 +19,10 @@ public class MainWindow : Adw.ApplicationWindow
|
|||||||
var conversation_list_page = new NavigationPage (conversation_list_view, "Conversations");
|
var conversation_list_page = new NavigationPage (conversation_list_view, "Conversations");
|
||||||
split_view.sidebar = conversation_list_page;
|
split_view.sidebar = conversation_list_page;
|
||||||
|
|
||||||
transcript_view = new TranscriptView ();
|
transcript_container_view = new TranscriptContainerView ();
|
||||||
transcript_view.on_send.connect (on_transcript_send);
|
transcript_container_view.on_send.connect (on_transcript_send);
|
||||||
|
|
||||||
var transcript_page = new NavigationPage (transcript_view, "Transcript");
|
var transcript_page = new NavigationPage (transcript_container_view, "Transcript");
|
||||||
split_view.content = transcript_page;
|
split_view.content = transcript_page;
|
||||||
|
|
||||||
var show_settings_action = new SimpleAction ("settings", null);
|
var show_settings_action = new SimpleAction ("settings", null);
|
||||||
@@ -37,27 +37,36 @@ public class MainWindow : Adw.ApplicationWindow
|
|||||||
|
|
||||||
private void conversation_selected(string? conversation_guid) {
|
private void conversation_selected(string? conversation_guid) {
|
||||||
if (conversation_guid == null) {
|
if (conversation_guid == null) {
|
||||||
transcript_view.message_list.model = null;
|
transcript_container_view.transcript_view.model = null;
|
||||||
} else {
|
} else {
|
||||||
if (transcript_view.message_list.model == null || transcript_view.message_list.model.conversation_guid != conversation_guid) {
|
if (transcript_container_view.transcript_view.model == null || transcript_container_view.transcript_view.model.conversation_guid != conversation_guid) {
|
||||||
transcript_view.message_list.model = new MessageListModel (conversation_guid);
|
transcript_container_view.transcript_view.model = new MessageListModel (conversation_guid);
|
||||||
|
|
||||||
|
try {
|
||||||
Repository.get_instance().sync_conversation(conversation_guid);
|
Repository.get_instance().sync_conversation(conversation_guid);
|
||||||
|
} catch (Error e) {
|
||||||
|
GLib.warning("Failed to sync conversation: %s", e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_transcript_send(string message) {
|
private void on_transcript_send(string message) {
|
||||||
if (transcript_view.message_list.model == null) {
|
if (transcript_container_view.transcript_view.model == null) {
|
||||||
GLib.warning("No conversation selected");
|
GLib.warning("No conversation selected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var selected_conversation = transcript_view.message_list.model.conversation_guid;
|
var selected_conversation = transcript_container_view.transcript_view.model.conversation_guid;
|
||||||
if (selected_conversation == null) {
|
if (selected_conversation == null) {
|
||||||
GLib.warning("No conversation selected");
|
GLib.warning("No conversation selected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
Repository.get_instance().send_message(selected_conversation, message);
|
Repository.get_instance().send_message(selected_conversation, message);
|
||||||
|
} catch (Error e) {
|
||||||
|
GLib.warning("Failed to send message: %s", e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,19 +28,21 @@ sources = [
|
|||||||
'conversation-list/conversation-list-model.vala',
|
'conversation-list/conversation-list-model.vala',
|
||||||
'conversation-list/conversation-row.vala',
|
'conversation-list/conversation-row.vala',
|
||||||
|
|
||||||
'message-list/message-list-view.vala',
|
'transcript/transcript-container-view.vala',
|
||||||
'message-list/message-list-model.vala',
|
'transcript/transcript-drawing-area.vala',
|
||||||
'message-list/message-drawing-area.vala',
|
|
||||||
|
|
||||||
'message-list/layouts/bubble-layout.vala',
|
'transcript/message-list-view.vala',
|
||||||
'message-list/layouts/chat-item-layout.vala',
|
'transcript/message-list-model.vala',
|
||||||
'message-list/layouts/date-item-layout.vala',
|
|
||||||
'message-list/layouts/text-bubble-layout.vala',
|
'transcript/layouts/bubble-layout.vala',
|
||||||
|
'transcript/layouts/chat-item-layout.vala',
|
||||||
|
'transcript/layouts/date-item-layout.vala',
|
||||||
|
'transcript/layouts/text-bubble-layout.vala',
|
||||||
|
|
||||||
'models/conversation.vala',
|
'models/conversation.vala',
|
||||||
'models/message.vala',
|
'models/message.vala',
|
||||||
|
|
||||||
'transcript-view/transcript-view.vala',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
executable('kordophone',
|
executable('kordophone',
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
transform: scale(1, -1);
|
transform: scale(1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-drawing-area {
|
.transcript-drawing-area {
|
||||||
color: darker(@accent_bg_color);
|
color: darker(@accent_bg_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using Adw;
|
|||||||
using Gtk;
|
using Gtk;
|
||||||
using Gee;
|
using Gee;
|
||||||
|
|
||||||
public class MessageListView : Adw.Bin
|
public class TranscriptView : Adw.Bin
|
||||||
{
|
{
|
||||||
public MessageListModel? model {
|
public MessageListModel? model {
|
||||||
get {
|
get {
|
||||||
@@ -15,7 +15,7 @@ public class MessageListView : Adw.Bin
|
|||||||
model.messages_changed.connect(reload_messages);
|
model.messages_changed.connect(reload_messages);
|
||||||
model.load_messages();
|
model.load_messages();
|
||||||
} else {
|
} else {
|
||||||
message_drawing_area.set_messages(new TreeSet<Message>());
|
transcript_drawing_area.set_messages(new TreeSet<Message>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,16 +23,16 @@ public class MessageListView : Adw.Bin
|
|||||||
private MessageListModel? _model = null;
|
private MessageListModel? _model = null;
|
||||||
private Adw.ToolbarView container;
|
private Adw.ToolbarView container;
|
||||||
|
|
||||||
private MessageDrawingArea message_drawing_area = new MessageDrawingArea();
|
private TranscriptDrawingArea transcript_drawing_area = new TranscriptDrawingArea();
|
||||||
private ScrolledWindow scrolled_window = new ScrolledWindow();
|
private ScrolledWindow scrolled_window = new ScrolledWindow();
|
||||||
|
|
||||||
public MessageListView(MessageListModel? model = null) {
|
public TranscriptView(MessageListModel? model = null) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
|
||||||
container = new Adw.ToolbarView();
|
container = new Adw.ToolbarView();
|
||||||
set_child(container);
|
set_child(container);
|
||||||
|
|
||||||
scrolled_window.set_child(message_drawing_area);
|
scrolled_window.set_child(transcript_drawing_area);
|
||||||
scrolled_window.add_css_class("message-list-scroller");
|
scrolled_window.add_css_class("message-list-scroller");
|
||||||
container.set_content(scrolled_window);
|
container.set_content(scrolled_window);
|
||||||
|
|
||||||
@@ -42,6 +42,6 @@ public class MessageListView : Adw.Bin
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void reload_messages() {
|
private void reload_messages() {
|
||||||
message_drawing_area.set_messages(_model.messages);
|
transcript_drawing_area.set_messages(_model.messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
using Gtk;
|
using Gtk;
|
||||||
using Adw;
|
using Adw;
|
||||||
|
|
||||||
class TranscriptView : Adw.Bin {
|
class TranscriptContainerView : Adw.Bin {
|
||||||
public MessageListView message_list;
|
public TranscriptView transcript_view;
|
||||||
public Entry message_entry;
|
public Entry message_entry;
|
||||||
public signal void on_send(string message);
|
public signal void on_send(string message);
|
||||||
|
|
||||||
private Box container;
|
private Box container;
|
||||||
private Button send_button;
|
private Button send_button;
|
||||||
|
|
||||||
public TranscriptView () {
|
public TranscriptContainerView () {
|
||||||
container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
|
container = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
|
||||||
set_child (container);
|
set_child (container);
|
||||||
|
|
||||||
// Create message list view
|
// Create message list view
|
||||||
message_list = new MessageListView();
|
transcript_view = new TranscriptView();
|
||||||
message_list.set_vexpand(true);
|
transcript_view.set_vexpand(true);
|
||||||
container.append(message_list);
|
container.append(transcript_view);
|
||||||
|
|
||||||
// Create bottom box for input
|
// Create bottom box for input
|
||||||
var input_box = new Box(Orientation.HORIZONTAL, 6);
|
var input_box = new Box(Orientation.HORIZONTAL, 6);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Gtk;
|
using Gtk;
|
||||||
using Gee;
|
using Gee;
|
||||||
|
|
||||||
private class MessageDrawingArea : Widget
|
private class TranscriptDrawingArea : Widget
|
||||||
{
|
{
|
||||||
private SortedSet<Message> _messages = new TreeSet<Message>();
|
private SortedSet<Message> _messages = new TreeSet<Message>();
|
||||||
private ArrayList<ChatItemLayout> _chat_items = new ArrayList<ChatItemLayout>();
|
private ArrayList<ChatItemLayout> _chat_items = new ArrayList<ChatItemLayout>();
|
||||||
@@ -9,8 +9,8 @@ private class MessageDrawingArea : Widget
|
|||||||
private const float bubble_padding = 10.0f;
|
private const float bubble_padding = 10.0f;
|
||||||
private const float bubble_margin = 18.0f;
|
private const float bubble_margin = 18.0f;
|
||||||
|
|
||||||
public MessageDrawingArea() {
|
public TranscriptDrawingArea() {
|
||||||
add_css_class("message-drawing-area");
|
add_css_class("transcript-drawing-area");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set_messages(SortedSet<Message> messages) {
|
public void set_messages(SortedSet<Message> messages) {
|
||||||
Reference in New Issue
Block a user