diff options
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/ui/conversation_selector/conversation_row.vala | 2 | ||||
-rw-r--r-- | main/src/ui/conversation_selector/groupchat_row.vala | 6 | ||||
-rw-r--r-- | main/src/ui/conversation_titlebar/view.vala | 23 | ||||
-rw-r--r-- | main/src/ui/util/helper.vala | 8 |
4 files changed, 25 insertions, 14 deletions
diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala index d79b840b..ea0aeeb4 100644 --- a/main/src/ui/conversation_selector/conversation_row.vala +++ b/main/src/ui/conversation_selector/conversation_row.vala @@ -61,7 +61,7 @@ public abstract class ConversationRow : ListBoxRow { update_read(); } - protected void update_name_label(string? new_name = null) { + protected void update_name_label() { name_label.label = Util.get_conversation_display_name(stream_interactor, conversation); } diff --git a/main/src/ui/conversation_selector/groupchat_row.vala b/main/src/ui/conversation_selector/groupchat_row.vala index fdbfa40b..70b24dfd 100644 --- a/main/src/ui/conversation_selector/groupchat_row.vala +++ b/main/src/ui/conversation_selector/groupchat_row.vala @@ -12,6 +12,12 @@ public class GroupchatRow : ConversationRow { closed.connect(() => { stream_interactor.get_module(MucManager.IDENTITY).part(conversation.account, conversation.counterpart); }); + + stream_interactor.get_module(MucManager.IDENTITY).room_name_set.connect((account, jid, room_name) => { + if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { + update_name_label(); + } + }); } protected override void update_message_label() { diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala index 4ca57e1c..924ca15e 100644 --- a/main/src/ui/conversation_titlebar/view.vala +++ b/main/src/ui/conversation_titlebar/view.vala @@ -36,9 +36,15 @@ public class ConversationTitlebar : Gtk.HeaderBar { } + stream_interactor.get_module(MucManager.IDENTITY).room_name_set.connect((account, jid, room_name) => { + if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { + update_title(); + } + }); + stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => { if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { - update_subtitle(subject); + update_subtitle(); } }); } @@ -57,17 +63,10 @@ public class ConversationTitlebar : Gtk.HeaderBar { set_title(Util.get_conversation_display_name(stream_interactor, conversation)); } - private void update_subtitle(string? subtitle = null) { - if (subtitle != null) { - set_subtitle(subtitle); - } else if (conversation.type_ == Conversation.Type.GROUPCHAT) { - string? subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account); - if (subject != null) { - subject = (new Regex("\\s+")).replace_literal(subject, -1, 0, " "); - } - set_subtitle(subject != "" ? subject : null); - } else { - set_subtitle(null); + private void update_subtitle() { + if (conversation.type_ == Conversation.Type.GROUPCHAT) { + string groupchat_subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account); + set_subtitle(groupchat_subject); } } } diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 9472c965..e2c8840f 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -59,7 +59,13 @@ public static string get_conversation_display_name(StreamInteractor stream_inter } public static string get_display_name(StreamInteractor stream_interactor, Jid jid, Account account) { - if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid, account)) { + if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat(jid, account)) { + string room_name = stream_interactor.get_module(MucManager.IDENTITY).get_room_name(account, jid); + if (room_name != null) { + return room_name; + } + return jid.bare_jid.to_string(); + } else if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid, account)) { return jid.resourcepart; } else { if (jid.equals_bare(account.bare_jid)) { |