mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Fixes Statusbar tabs and Cleanup
- Fixes statusbar tabs. Bug: Statusbar used nickname if it was set in roster, irrelevant to /statusbar chat setting. Expected behaviour would be using this setting set as "user" to show nickname, and to show jid with "jid" setting. Other solution is to give a user control over it with another settings. - _status_bar_draw_maintext cleaned up, no changes to behaviour
This commit is contained in:
parent
0740d692dc
commit
7d290b04d5
@ -182,10 +182,7 @@ status_bar_inactive(const int win)
|
|||||||
void
|
void
|
||||||
_create_tab(const int win, win_type_t wintype, char* identifier, gboolean highlight)
|
_create_tab(const int win, win_type_t wintype, char* identifier, gboolean highlight)
|
||||||
{
|
{
|
||||||
int true_win = win;
|
int true_win = win == 0 ? 10 : win;
|
||||||
if (true_win == 0) {
|
|
||||||
true_win = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusBarTab* tab = malloc(sizeof(StatusBarTab));
|
StatusBarTab* tab = malloc(sizeof(StatusBarTab));
|
||||||
tab->identifier = strdup(identifier);
|
tab->identifier = strdup(identifier);
|
||||||
@ -198,11 +195,12 @@ _create_tab(const int win, win_type_t wintype, char* identifier, gboolean highli
|
|||||||
if (roster_exists()) {
|
if (roster_exists()) {
|
||||||
contact = roster_get_contact(tab->identifier);
|
contact = roster_get_contact(tab->identifier);
|
||||||
}
|
}
|
||||||
if (contact && p_contact_name(contact)) {
|
const char* pcontact_name = contact ? p_contact_name(contact) : NULL;
|
||||||
tab->display_name = strdup(p_contact_name(contact));
|
auto_char char* pref = prefs_get_string(PREF_STATUSBAR_CHAT);
|
||||||
} else {
|
if (g_strcmp0("user", pref) == 0) {
|
||||||
char* pref = prefs_get_string(PREF_STATUSBAR_CHAT);
|
if (pcontact_name) {
|
||||||
if (g_strcmp0("user", pref) == 0) {
|
tab->display_name = strdup(pcontact_name);
|
||||||
|
} else {
|
||||||
Jid* jidp = jid_create(tab->identifier);
|
Jid* jidp = jid_create(tab->identifier);
|
||||||
if (jidp) {
|
if (jidp) {
|
||||||
tab->display_name = jidp->localpart != NULL ? strdup(jidp->localpart) : strdup(jidp->barejid);
|
tab->display_name = jidp->localpart != NULL ? strdup(jidp->localpart) : strdup(jidp->barejid);
|
||||||
@ -210,10 +208,9 @@ _create_tab(const int win, win_type_t wintype, char* identifier, gboolean highli
|
|||||||
} else {
|
} else {
|
||||||
tab->display_name = strdup(tab->identifier);
|
tab->display_name = strdup(tab->identifier);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
tab->display_name = strdup(tab->identifier);
|
|
||||||
}
|
}
|
||||||
g_free(pref);
|
} else {
|
||||||
|
tab->display_name = strdup(tab->identifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,12 +515,17 @@ _status_bar_draw_maintext(int pos)
|
|||||||
const char* maintext = NULL;
|
const char* maintext = NULL;
|
||||||
auto_jid Jid* jidp = NULL;
|
auto_jid Jid* jidp = NULL;
|
||||||
auto_char char* self = prefs_get_string(PREF_STATUSBAR_SELF);
|
auto_char char* self = prefs_get_string(PREF_STATUSBAR_SELF);
|
||||||
|
|
||||||
if (statusbar->prompt) {
|
if (statusbar->prompt) {
|
||||||
mvwprintw(statusbar_win, 0, pos, "%s", statusbar->prompt);
|
mvwprintw(statusbar_win, 0, pos, "%s", statusbar->prompt);
|
||||||
return utf8_display_len(statusbar->prompt);
|
return utf8_display_len(statusbar->prompt);
|
||||||
} else if (g_strcmp0(self, "off") == 0) {
|
}
|
||||||
|
|
||||||
|
if (g_strcmp0(self, "off") == 0) {
|
||||||
return pos;
|
return pos;
|
||||||
} else if (statusbar->fulljid) {
|
}
|
||||||
|
|
||||||
|
if (statusbar->fulljid) {
|
||||||
jidp = jid_create(statusbar->fulljid);
|
jidp = jid_create(statusbar->fulljid);
|
||||||
if (g_strcmp0(self, "user") == 0) {
|
if (g_strcmp0(self, "user") == 0) {
|
||||||
maintext = jidp->localpart;
|
maintext = jidp->localpart;
|
||||||
@ -538,6 +540,28 @@ _status_bar_draw_maintext(int pos)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (statusbar->fulljid) {
|
||||||
|
auto_char char* pref = prefs_get_string(PREF_STATUSBAR_SELF);
|
||||||
|
|
||||||
|
if (g_strcmp0(pref, "off") == 0) {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
if (g_strcmp0(pref, "user") == 0) {
|
||||||
|
Jid* jidp = jid_create(statusbar->fulljid);
|
||||||
|
mvwprintw(statusbar_win, 0, pos, "%s", jidp->localpart);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
if (g_strcmp0(pref, "barejid") == 0) {
|
||||||
|
Jid* jidp = jid_create(statusbar->fulljid);
|
||||||
|
mvwprintw(statusbar_win, 0, pos, "%s", jidp->barejid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
mvwprintw(statusbar_win, 0, pos, "%s", statusbar->fulljid);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean actlist_tabmode = _tabmode_is_actlist();
|
gboolean actlist_tabmode = _tabmode_is_actlist();
|
||||||
auto_gchar gchar* maintext_ = NULL;
|
auto_gchar gchar* maintext_ = NULL;
|
||||||
if (actlist_tabmode) {
|
if (actlist_tabmode) {
|
||||||
|
@ -328,7 +328,7 @@ win_get_title(ProfWin* window)
|
|||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return strdup(chatwin->barejid);
|
return strdup(chatwin->barejid);
|
||||||
}
|
}
|
||||||
if(show_titlebar_jid){
|
if (show_titlebar_jid) {
|
||||||
return g_strdup_printf("%s <%s>", name, chatwin->barejid);
|
return g_strdup_printf("%s <%s>", name, chatwin->barejid);
|
||||||
}
|
}
|
||||||
return g_strdup_printf("%s", name);
|
return g_strdup_printf("%s", name);
|
||||||
|
Loading…
Reference in New Issue
Block a user