mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
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.
This commit is contained in:
parent
54cf152130
commit
0740d692dc
@ -1260,8 +1260,8 @@ static const struct cmd_t command_defs[] = {
|
|||||||
{ "show tls", "Show or hide TLS indicator in the titlebar." },
|
{ "show tls", "Show or hide TLS indicator in the titlebar." },
|
||||||
{ "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." },
|
{ "show encwarn", "Enable or disable the unencrypted warning message in the titlebar." },
|
||||||
{ "show resource", "Show or hide the current resource in the titlebar." },
|
{ "show resource", "Show or hide the current resource in the titlebar." },
|
||||||
{ "show name", "In case of a MUC. Show the MUC name in the titlebar." },
|
{ "show name", "Show the nickname or MUC name in the titlebar." },
|
||||||
{ "show jid", "In case of a MUC. Show the JID in the titlebar." })
|
{ "show jid", "Show the JID in the titlebar." })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/titlebar up",
|
"/titlebar up",
|
||||||
"/titlebar show tls",
|
"/titlebar show tls",
|
||||||
|
@ -312,18 +312,26 @@ win_get_title(ProfWin* window)
|
|||||||
{
|
{
|
||||||
ProfChatWin* chatwin = (ProfChatWin*)window;
|
ProfChatWin* chatwin = (ProfChatWin*)window;
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
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();
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
if (conn_status == JABBER_CONNECTED) {
|
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
if (conn_status != JABBER_CONNECTED || !show_titlebar_name) {
|
||||||
if (contact) {
|
|
||||||
const char* name = p_contact_name_or_jid(contact);
|
|
||||||
return strdup(name);
|
|
||||||
} else {
|
|
||||||
return strdup(chatwin->barejid);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return strdup(chatwin->barejid);
|
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:
|
case WIN_MUC:
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user