1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 16:13:27 +01:00

move window blink/beep to a function

This commit is contained in:
Jfreegman 2013-11-19 02:31:22 -05:00
parent 83458c64ec
commit b16ff16abc
4 changed files with 17 additions and 14 deletions

View File

@ -41,8 +41,7 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *msg, uint1
} else
wprintw(ctx->history, "%s\n", msg);
self->blink = true;
beep();
alert_window(self);
}
static void chat_onConnectionChange(ToxWindow *self, Tox *m, int num, uint8_t status)
@ -70,8 +69,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int num, uint8_t *action, uin
wprintw(ctx->history, "* %s %s\n", nick, action);
wattroff(ctx->history, COLOR_PAIR(YELLOW));
self->blink = true;
beep();
alert_window(self);
}
static void chat_onNickChange(ToxWindow *self, int num, uint8_t *nick, uint16_t len)
@ -155,8 +153,7 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int num, uint8_t fil
friends[num].file_receiver.pending[filenum] = true;
strcpy(friends[num].file_receiver.filenames[filenum], filename);
self->blink = true;
beep();
alert_window(self);
}
static void chat_onFileControl(ToxWindow *self, Tox *m, int num, uint8_t receive_send,
@ -189,8 +186,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int num, uint8_t receive
break;
}
self->blink = true;
beep();
alert_window(self);
}
static void chat_onFileData(ToxWindow *self, Tox *m, int num, uint8_t filenum, uint8_t *data,
@ -232,10 +228,8 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int friendnumber, uint8_
}
memcpy(friends[friendnumber].pending_groupchat, group_pub_key, TOX_CLIENT_ID_SIZE);
wprintw(ctx->history, "Type \"/join\" to join the chat.\n");
self->blink = true;
beep();
alert_window(self);
}
static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action) {

View File

@ -106,3 +106,10 @@ bool timed_out(uint64_t timestamp, uint64_t curtime, uint64_t timeout)
{
return timestamp + timeout <= curtime;
}
/* Beeps and makes window tab blink */
void alert_window(ToxWindow *self)
{
self->blink = true;
beep();
}

View File

@ -22,3 +22,6 @@ char *wc_to_char(wchar_t ch);
/* Returns true if connection has timed out, false otherwise */
bool timed_out(uint64_t timestamp, uint64_t timeout, uint64_t curtime);
/* Beeps and makes window tab blink */
void alert_window(ToxWindow *self);

View File

@ -227,8 +227,7 @@ static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data,
}
wprintw(self->window, "Type \"/accept %d\" to accept it.\n", n);
self->blink = true;
beep();
alert_window(self);
}
void prompt_init_statusbar(ToxWindow *self, Tox *m)