From 766ae685c2d0850516d6ab3db83c00fdb7f5d973 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 11 Apr 2014 21:47:09 -0400 Subject: [PATCH] add setting to disable terminal alerts --- misc/toxic.conf | 3 +++ src/misc_tools.c | 2 +- src/settings.c | 6 ++++++ src/settings.h | 6 +++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/misc/toxic.conf b/misc/toxic.conf index 3c763db..b480f4f 100644 --- a/misc/toxic.conf +++ b/misc/toxic.conf @@ -4,6 +4,9 @@ time:24; # 1 to enable autologging, 0 to disable autolog:0; +# 1 to disbale terminal alerts on messages, 0 to enable +disable_alerts:0; + # 1 to use native terminal colours, 0 to use toxic default colour theme colour_theme:0; diff --git a/src/misc_tools.c b/src/misc_tools.c index 627d863..31ef296 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -189,7 +189,7 @@ void alert_window(ToxWindow *self, int type, bool is_beep) StatusBar *stb = prompt->stb; - if (is_beep && stb->status != TOX_USERSTATUS_BUSY) + if (is_beep && stb->status != TOX_USERSTATUS_BUSY && user_settings->alerts == ALERTS_ENABLED) beep(); } diff --git a/src/settings.c b/src/settings.c index 62b6e4e..df3d0b0 100644 --- a/src/settings.c +++ b/src/settings.c @@ -30,6 +30,7 @@ static void uset_autolog(struct user_settings *s, int val); static void uset_time(struct user_settings *s, int val); +static void uset_alerts(struct user_settings *s, int val); static void uset_colours(struct user_settings *s, int val); static void uset_ain_dev(struct user_settings *s, int val); static void uset_aout_dev(struct user_settings *s, int val); @@ -40,6 +41,7 @@ struct { } user_settings_list[] = { { "autolog", uset_autolog }, { "time", uset_time }, + { "disable_alerts", uset_alerts }, { "colour_theme", uset_colours }, { "audio_in_dev", uset_ain_dev }, { "audio_out_dev", uset_aout_dev }, @@ -57,6 +59,10 @@ static void uset_time(struct user_settings *s, int val) s->time = val == TIME_12 ? TIME_12 : TIME_24; } +static void uset_alerts(struct user_settings *s, int val) +{ + s->alerts = val == ALERTS_DISABLED ? ALERTS_DISABLED : ALERTS_ENABLED; +} static void uset_colours(struct user_settings *s, int val) { /* use default toxic colours if invalid value */ diff --git a/src/settings.h b/src/settings.h index 47ea552..4c75051 100644 --- a/src/settings.h +++ b/src/settings.h @@ -20,11 +20,12 @@ * */ -#define NUM_SETTINGS 5 +#define NUM_SETTINGS 6 /* holds user setting values */ struct user_settings { int autolog; /* boolean */ + int alerts; /* boolean */ int time; /* 12 or 24 */ int colour_theme; /* boolean (0 for default toxic colours) */ long int audio_in_dev; @@ -38,6 +39,9 @@ enum { TIME_24 = 24, TIME_12 = 12, + ALERTS_DISABLED = 1, + ALERTS_ENABLED = 0, + NATIVE_COLS = 1, DFLT_COLS = 0, };