From ea0479998a0d44eb2a02c5ec18a692b17aa53274 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 14 Apr 2013 11:56:50 +0200 Subject: [PATCH] Use bundled beep file for beep alerts --- src/common/cfgfiles.c | 2 +- src/common/ctcp.c | 2 +- src/common/outbound.c | 2 +- src/common/text.c | 10 +++++----- src/common/text.h | 2 +- src/fe-gtk/fe-gtk.c | 12 +++++++++++- src/fe-gtk/setup.c | 2 +- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 4b8a4c8d..712f2bfa 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -843,7 +843,7 @@ load_config (void) g_free (buf); buf = g_build_filename (get_xdir (), "sounds", "beep.wav", NULL); -#ifdef WIN32 +#ifdef WIN32 /* keep this in sync with fe-gtk.c! */ beepsrc = g_file_new_for_path (HEXCHATSHAREDIR G_DIR_SEPARATOR_S "share" G_DIR_SEPARATOR_S "beep.wav"); #else beepsrc = g_file_new_for_path (HEXCHATSHAREDIR G_DIR_SEPARATOR_S "hexchat" G_DIR_SEPARATOR_S "beep.wav"); diff --git a/src/common/ctcp.c b/src/common/ctcp.c index ebfb604d..487003a8 100644 --- a/src/common/ctcp.c +++ b/src/common/ctcp.c @@ -175,7 +175,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, #else if (strchr (word[5], '/') == NULL) #endif - sound_play (word[5], TRUE); + sound_play (word[5], TRUE, FALSE); return; } } diff --git a/src/common/outbound.c b/src/common/outbound.c index d6ce1488..00ba4a86 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -3161,7 +3161,7 @@ cmd_splay (struct session *sess, char *tbuf, char *word[], char *word_eol[]) { if (*word[2]) { - sound_play (word[2], FALSE); + sound_play (word[2], FALSE, FALSE); return TRUE; } diff --git a/src/common/text.c b/src/common/text.c index 946ac542..3a61eecc 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -2218,7 +2218,7 @@ sound_find_command (void) } void -sound_play (const char *file, gboolean quiet) +sound_play (const char *file, gboolean quiet, gboolean hexchat_beep) { char *buf; char *wavfile; @@ -2233,10 +2233,10 @@ sound_play (const char *file, gboolean quiet) return; #ifdef WIN32 - /* check for fullpath */ - if (file[0] == '\\' || (((file[0] >= 'A' && file[0] <= 'Z') || (file[0] >= 'a' && file[0] <= 'z')) && file[1] == ':')) + /* check for fullpath; also use full path if hexchat_beep is TRUE, which should *only* happen when invoked by fe_beep() */ + if (hexchat_beep || file[0] == '\\' || (((file[0] >= 'A' && file[0] <= 'Z') || (file[0] >= 'a' && file[0] <= 'z')) && file[1] == ':')) #else - if (file[0] == '/') + if (hexchat_beep || file[0] == '/') #endif { wavfile = g_strdup (file); @@ -2308,7 +2308,7 @@ void sound_play_event (int i) { if (sound_files[i]) - sound_play (sound_files[i], FALSE); + sound_play (sound_files[i], FALSE, FALSE); } static void diff --git a/src/common/text.h b/src/common/text.h index 52cc8ea9..4d7bbb38 100644 --- a/src/common/text.h +++ b/src/common/text.h @@ -53,7 +53,7 @@ int get_stamp_str (char *fmt, time_t tim, char **ret); void format_event (session *sess, int index, char **args, char *o, int sizeofo, unsigned int stripcolor_args); char *text_find_format_string (char *name); -void sound_play (const char *file, gboolean quiet); +void sound_play (const char *file, gboolean quiet, gboolean hexchat_beep); void sound_play_event (int i); void sound_beep (session *); void sound_load (); diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 52d4a906..c9c384cc 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -669,8 +669,18 @@ fe_print_text (struct session *sess, char *text, time_t stamp) void fe_beep (session *sess) { + char *beepfile; + if (!prefs.hex_gui_focus_omitalerts || !fe_gui_info (sess, 0) == 1) - gdk_beep (); + { +#ifdef WIN32 /* keep this in sync with cfgfiles.c! */ + beepfile = g_build_filename (HEXCHATSHAREDIR, "share", "beep.wav", NULL); +#else + beepfile = g_build_filename (HEXCHATSHAREDIR, "hexchat", "beep.wav", NULL); +#endif + sound_play (beepfile, FALSE, TRUE); + g_free (beepfile); + } } void diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index e8cca3a7..261d29d9 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -1654,7 +1654,7 @@ setup_snd_browse_cb (GtkWidget *button, GtkEntry *entry) static void setup_snd_play_cb (GtkWidget *button, GtkEntry *entry) { - sound_play (entry->text, FALSE); + sound_play (entry->text, FALSE, FALSE); } static void