Show conversation display name in title
This commit is contained in:
@@ -35,15 +35,17 @@ public class MainWindow : Adw.ApplicationWindow
|
||||
dialog.present (this);
|
||||
}
|
||||
|
||||
private void conversation_selected(string? conversation_guid) {
|
||||
if (conversation_guid == null) {
|
||||
transcript_container_view.transcript_view.model = null;
|
||||
private void conversation_selected(Conversation conversation) {
|
||||
TranscriptView transcript_view = transcript_container_view.transcript_view;
|
||||
if (conversation == null) {
|
||||
transcript_view.model = null;
|
||||
} else {
|
||||
if (transcript_container_view.transcript_view.model == null || transcript_container_view.transcript_view.model.conversation_guid != conversation_guid) {
|
||||
transcript_container_view.transcript_view.model = new MessageListModel (conversation_guid);
|
||||
if (transcript_view.model == null || transcript_view.model.conversation_guid != conversation.guid) {
|
||||
transcript_view.model = new MessageListModel (conversation.guid);
|
||||
transcript_view.title = conversation.display_name;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,16 @@ public class ConversationListModel : Object, ListModel
|
||||
Repository.get_instance().conversations_updated.connect(load_conversations);
|
||||
Repository.get_instance().messages_updated.connect(load_conversations);
|
||||
}
|
||||
|
||||
public Conversation? get_conversation(string guid) {
|
||||
foreach (var conv in _conversations) {
|
||||
if (conv.guid == guid) {
|
||||
return conv;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void load_conversations() {
|
||||
try {
|
||||
|
||||
@@ -3,7 +3,7 @@ using Gtk;
|
||||
|
||||
public class ConversationListView : Adw.Bin
|
||||
{
|
||||
public signal void conversation_selected(string? conversation_guid);
|
||||
public signal void conversation_selected(Conversation conversation);
|
||||
|
||||
private Adw.ToolbarView container;
|
||||
private ListBox list_box;
|
||||
@@ -30,7 +30,9 @@ public class ConversationListView : Adw.Bin
|
||||
var conversation_row = (ConversationRow?) row;
|
||||
if (conversation_row != null) {
|
||||
selected_conversation_guid = conversation_row.conversation.guid;
|
||||
conversation_selected(selected_conversation_guid);
|
||||
|
||||
Conversation conversation = conversation_model.get_conversation(selected_conversation_guid);
|
||||
conversation_selected(conversation);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -20,8 +20,14 @@ public class TranscriptView : Adw.Bin
|
||||
}
|
||||
}
|
||||
|
||||
public string title {
|
||||
get { return title_label.label; }
|
||||
set { title_label.label = value; }
|
||||
}
|
||||
|
||||
private MessageListModel? _model = null;
|
||||
private Adw.ToolbarView container;
|
||||
private Label title_label = new Label("Messages");
|
||||
|
||||
private TranscriptDrawingArea transcript_drawing_area = new TranscriptDrawingArea();
|
||||
private ScrolledWindow scrolled_window = new ScrolledWindow();
|
||||
@@ -37,7 +43,7 @@ public class TranscriptView : Adw.Bin
|
||||
container.set_content(scrolled_window);
|
||||
|
||||
var header_bar = new Adw.HeaderBar();
|
||||
header_bar.set_title_widget(new Label("Messages"));
|
||||
header_bar.set_title_widget(title_label);
|
||||
container.add_top_bar(header_bar);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user