1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Tidy notify_message()

This commit is contained in:
James Booth 2016-02-04 00:41:53 +00:00
parent f8f9ad5197
commit c14ef33906
3 changed files with 12 additions and 31 deletions

View File

@ -280,20 +280,8 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
beep();
}
if (!notify) {
free(display_name);
return;
}
int ui_index = num;
if (ui_index == 10) {
ui_index = 0;
}
if (prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) {
notify_message(display_name, ui_index, message);
} else {
notify_message(display_name, ui_index, NULL);
if (notify) {
notify_message(display_name, num, message);
}
free(display_name);

View File

@ -98,11 +98,16 @@ notify_invite(const char *const from, const char *const room, const char *const
}
void
notify_message(const char *const name, int win, const char *const text)
notify_message(const char *const name, int num, const char *const text)
{
int ui_index = num;
if (ui_index == 10) {
ui_index = 0;
}
GString *message = g_string_new("");
g_string_append_printf(message, "%s (win %d)", name, win);
if (text) {
g_string_append_printf(message, "%s (win %d)", name, ui_index);
if (text && prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) {
g_string_append_printf(message, "\n%s", text);
}

View File

@ -85,20 +85,8 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
beep();
}
if (!notify) {
jid_destroy(jidp);
return;
}
int ui_index = num;
if (ui_index == 10) {
ui_index = 0;
}
if (prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) {
notify_message(jidp->resourcepart, ui_index, message);
} else {
notify_message(jidp->resourcepart, ui_index, NULL);
if (notify) {
notify_message(jidp->resourcepart, num, message);
}
jid_destroy(jidp);