1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #1259 from ailin-nemui/beep-ignore-opts

do not beep on hidden lines with /set beep_msg_level ... -hidden
This commit is contained in:
ailin-nemui 2021-04-18 12:01:03 +02:00 committed by GitHub
commit afdd9f8f05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 2 deletions

View File

@ -138,6 +138,23 @@ int settings_get_level(const char *key)
return str == NULL ? 0 : level2bits(str, NULL); return str == NULL ? 0 : level2bits(str, NULL);
} }
int settings_get_level_negative(const char *key)
{
const char *str, *tmp, *all_levels;
int levels;
str = settings_get_str_type(key, SETTING_TYPE_LEVEL);
if (str == NULL)
return 0;
all_levels = bits2level(~0);
tmp = g_strdup_printf("%s %s", all_levels, str);
levels = level2bits(tmp, NULL) ^ level2bits(all_levels, NULL);
g_free((char *) tmp);
g_free((char *) all_levels);
return levels;
}
int settings_get_size(const char *key) int settings_get_size(const char *key)
{ {
const char *str; const char *str;

View File

@ -66,6 +66,7 @@ int settings_get_int(const char *key);
int settings_get_bool(const char *key); int settings_get_bool(const char *key);
int settings_get_time(const char *key); /* as milliseconds */ int settings_get_time(const char *key); /* as milliseconds */
int settings_get_level(const char *key); int settings_get_level(const char *key);
int settings_get_level_negative(const char *key);
int settings_get_size(const char *key); /* as bytes */ int settings_get_size(const char *key); /* as bytes */
int settings_get_choice(const char *key); int settings_get_choice(const char *key);
char *settings_get_print(SETTINGS_REC *rec); char *settings_get_print(SETTINGS_REC *rec);

View File

@ -32,13 +32,14 @@
#include <irssi/src/fe-common/core/fe-windows.h> #include <irssi/src/fe-common/core/fe-windows.h>
#include <irssi/src/fe-common/core/printtext.h> #include <irssi/src/fe-common/core/printtext.h>
static int beep_msg_level, beep_when_away, beep_when_window_active; static int beep_msg_level, beep_msg_level_ignore, beep_when_away, beep_when_window_active;
static int signal_gui_print_text_finished; static int signal_gui_print_text_finished;
static int signal_print_starting; static int signal_print_starting;
static int signal_print_text; static int signal_print_text;
static int signal_print_format; static int signal_print_format;
static int signal_print_noformat; static int signal_print_noformat;
static int signal_window_hilight_check;
static int sending_print_starting; static int sending_print_starting;
@ -404,7 +405,18 @@ static void msg_beep_check(TEXT_DEST_REC *dest)
(beep_when_away || (dest->server != NULL && (beep_when_away || (dest->server != NULL &&
!dest->server->usermode_away)) && !dest->server->usermode_away)) &&
(beep_when_window_active || dest->window != active_win)) { (beep_when_window_active || dest->window != active_win)) {
signal_emit("beep", 0); if (beep_msg_level_ignore & MSGLEVEL_HIDDEN) {
int cb_ignore = 0;
if (signal_emit_id(signal_window_hilight_check, 4, dest, NULL, NULL,
&cb_ignore),
cb_ignore) {
return;
}
} else if (beep_msg_level_ignore & dest->level) {
return;
}
signal_emit("beep", 0);
} }
} }
@ -521,6 +533,7 @@ static void sig_gui_dialog(const char *type, const char *text)
static void read_settings(void) static void read_settings(void)
{ {
beep_msg_level = settings_get_level("beep_msg_level"); beep_msg_level = settings_get_level("beep_msg_level");
beep_msg_level_ignore = settings_get_level_negative("beep_msg_level");
beep_when_away = settings_get_bool("beep_when_away"); beep_when_away = settings_get_bool("beep_when_away");
beep_when_window_active = settings_get_bool("beep_when_window_active"); beep_when_window_active = settings_get_bool("beep_when_window_active");
} }
@ -533,6 +546,7 @@ void printtext_init(void)
signal_print_text = signal_get_uniq_id("print text"); signal_print_text = signal_get_uniq_id("print text");
signal_print_format = signal_get_uniq_id("print format"); signal_print_format = signal_get_uniq_id("print format");
signal_print_noformat = signal_get_uniq_id("print noformat"); signal_print_noformat = signal_get_uniq_id("print noformat");
signal_window_hilight_check = signal_get_uniq_id("window hilight check");
read_settings(); read_settings();
signal_add("print text", (SIGNAL_FUNC) sig_print_text); signal_add("print text", (SIGNAL_FUNC) sig_print_text);

View File

@ -96,6 +96,10 @@ int
settings_get_level(key) settings_get_level(key)
char *key char *key
int
settings_get_level_negative(key)
char *key
int int
settings_get_size(key) settings_get_size(key)
char *key char *key