about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-04-04 00:06:04 +0200
committerJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-04-10 11:04:20 +0200
commit0740d692dc401dd8614fcbc9f628086279ca3c93 (patch)
tree25184bded131a66afd30a25566afb1d6379392b3 /src/ui
parent54cf152130fe7829740a20780533ca2c8d957135 (diff)
downloadprofani-tty-0740d692dc401dd8614fcbc9f628086279ca3c93.tar.gz
Improve titlebar flexibility
Before this change, only nickname or JID (if no nickname set) is shown in the titlebar.
Change allows to alter nickname/JID preference
using already implemented /titlebar show jid|name setting.
If both are set to "show", then it is displayed in "nickname <JID>" format.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/window.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index c1d5edf3..6718d0c5 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -312,18 +312,26 @@ win_get_title(ProfWin* window)
     {
         ProfChatWin* chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
+
+        gboolean show_titlebar_jid = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID);
+        gboolean show_titlebar_name = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME);
         jabber_conn_status_t conn_status = connection_get_status();
-        if (conn_status == JABBER_CONNECTED) {
-            PContact contact = roster_get_contact(chatwin->barejid);
-            if (contact) {
-                const char* name = p_contact_name_or_jid(contact);
-                return strdup(name);
-            } else {
-                return strdup(chatwin->barejid);
-            }
-        } else {
+
+        if (conn_status != JABBER_CONNECTED || !show_titlebar_name) {
+            return strdup(chatwin->barejid);
+        }
+        PContact contact = roster_get_contact(chatwin->barejid);
+        if (!contact) {
             return strdup(chatwin->barejid);
         }
+        const char* name = p_contact_name(contact);
+        if (name == NULL) {
+            return strdup(chatwin->barejid);
+        }
+        if(show_titlebar_jid){
+            return g_strdup_printf("%s <%s>", name, chatwin->barejid);
+        }
+        return g_strdup_printf("%s", name);
     }
     case WIN_MUC:
     {