Show conversation display name in title
This commit is contained in:
@@ -35,15 +35,17 @@ public class MainWindow : Adw.ApplicationWindow
|
|||||||
dialog.present (this);
|
dialog.present (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void conversation_selected(string? conversation_guid) {
|
private void conversation_selected(Conversation conversation) {
|
||||||
if (conversation_guid == null) {
|
TranscriptView transcript_view = transcript_container_view.transcript_view;
|
||||||
transcript_container_view.transcript_view.model = null;
|
if (conversation == null) {
|
||||||
|
transcript_view.model = null;
|
||||||
} else {
|
} else {
|
||||||
if (transcript_container_view.transcript_view.model == null || transcript_container_view.transcript_view.model.conversation_guid != conversation_guid) {
|
if (transcript_view.model == null || transcript_view.model.conversation_guid != conversation.guid) {
|
||||||
transcript_container_view.transcript_view.model = new MessageListModel (conversation_guid);
|
transcript_view.model = new MessageListModel (conversation.guid);
|
||||||
|
transcript_view.title = conversation.display_name;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Repository.get_instance().sync_conversation(conversation_guid);
|
Repository.get_instance().sync_conversation(conversation.guid);
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
GLib.warning("Failed to sync conversation: %s", e.message);
|
GLib.warning("Failed to sync conversation: %s", e.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,16 @@ public class ConversationListModel : Object, ListModel
|
|||||||
Repository.get_instance().messages_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() {
|
public void load_conversations() {
|
||||||
try {
|
try {
|
||||||
Conversation[] new_conversations = Repository.get_instance().get_conversations();
|
Conversation[] new_conversations = Repository.get_instance().get_conversations();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Gtk;
|
|||||||
|
|
||||||
public class ConversationListView : Adw.Bin
|
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 Adw.ToolbarView container;
|
||||||
private ListBox list_box;
|
private ListBox list_box;
|
||||||
@@ -30,7 +30,9 @@ public class ConversationListView : Adw.Bin
|
|||||||
var conversation_row = (ConversationRow?) row;
|
var conversation_row = (ConversationRow?) row;
|
||||||
if (conversation_row != null) {
|
if (conversation_row != null) {
|
||||||
selected_conversation_guid = conversation_row.conversation.guid;
|
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 MessageListModel? _model = null;
|
||||||
private Adw.ToolbarView container;
|
private Adw.ToolbarView container;
|
||||||
|
private Label title_label = new Label("Messages");
|
||||||
|
|
||||||
private TranscriptDrawingArea transcript_drawing_area = new TranscriptDrawingArea();
|
private TranscriptDrawingArea transcript_drawing_area = new TranscriptDrawingArea();
|
||||||
private ScrolledWindow scrolled_window = new ScrolledWindow();
|
private ScrolledWindow scrolled_window = new ScrolledWindow();
|
||||||
@@ -37,7 +43,7 @@ public class TranscriptView : Adw.Bin
|
|||||||
container.set_content(scrolled_window);
|
container.set_content(scrolled_window);
|
||||||
|
|
||||||
var header_bar = new Adw.HeaderBar();
|
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);
|
container.add_top_bar(header_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user