diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/text.c | 51 | ||||
-rw-r--r-- | src/fe-gtk/setup.c | 19 |
2 files changed, 29 insertions, 41 deletions
diff --git a/src/common/text.c b/src/common/text.c index 709e05ef..da677c88 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -2226,14 +2226,12 @@ sound_play (const char *file, gboolean quiet, gboolean hexchat_beep) char *buf; char *wavfile; char *cmd; -#if 0 - LPSTR lpRes; - HANDLE hResInfo, hRes; -#endif /* the pevents GUI editor triggers this after removing a soundfile */ if (!file[0]) + { return; + } #ifdef WIN32 /* check for fullpath; also use full path if hexchat_beep is TRUE, which should *only* happen when invoked by fe_beep() */ @@ -2251,48 +2249,19 @@ sound_play (const char *file, gboolean quiet, gboolean hexchat_beep) if (g_access (wavfile, R_OK) == 0) { +#ifdef WIN32 + PlaySound (wavfile, NULL, SND_NODEFAULT|SND_FILENAME|SND_ASYNC); +#else cmd = sound_find_command (); -#ifdef WIN32 - if (cmd == NULL || strcmp (cmd, "esdplay") == 0) + if (cmd) { - PlaySound (wavfile, NULL, SND_NODEFAULT|SND_FILENAME|SND_ASYNC); -#if 0 /* this would require the wav file to be added to the executable as resource */ - hResInfo = FindResource (NULL, file_fs, "WAVE"); - if (hResInfo != NULL) - { - /* load the WAVE resource */ - hRes = LoadResource (NULL, hResInfo); - if (hRes != NULL) - { - /* lock the WAVE resource and play it */ - lpRes = LockResource(hRes); - if (lpRes != NULL) - { - sndPlaySound (lpRes, SND_MEMORY | SND_NODEFAULT | SND_FILENAME | SND_ASYNC); - UnlockResource (hRes); - } - - /* free the WAVE resource */ - FreeResource (hRes); - } - } -#endif + buf = g_strdup_printf ("%s \"%s\"", cmd, wavfile); + hexchat_exec (buf); + g_free (buf); + g_free (cmd); } - else #endif - { - if (cmd) - { - buf = g_strdup_printf ("%s \"%s\"", cmd, wavfile); - hexchat_exec (buf); - g_free (buf); - } - } - - if (cmd) - g_free (cmd); - } else { diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 70e82c9a..02e8605d 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -1518,18 +1518,22 @@ setup_create_color_page (void) /* === GLOBALS for sound GUI === */ +#ifndef WIN32 static GtkWidget *sndprog_entry; +#endif static GtkWidget *sndfile_entry; static int ignore_changed = FALSE; extern struct text_event te[]; /* text.c */ extern char *sound_files[]; +#ifndef WIN32 static void setup_snd_apply (void) { strcpy (setup_prefs.hex_sound_command, GTK_ENTRY (sndprog_entry)->text); } +#endif static void setup_snd_populate (GtkTreeView * treeview) @@ -1619,6 +1623,7 @@ setup_snd_add_columns (GtkTreeView * treeview) g_object_unref (model); } +#ifndef WIN32 static void setup_autotoggle_cb (GtkToggleButton *but, GtkToggleButton *ext) { @@ -1632,6 +1637,7 @@ setup_autotoggle_cb (GtkToggleButton *but, GtkToggleButton *ext) gtk_widget_set_sensitive (sndprog_entry, TRUE); } } +#endif static void setup_snd_filereq_cb (GtkWidget *entry, char *file) @@ -1690,12 +1696,19 @@ setup_create_sound_page (void) { GtkWidget *vbox1; GtkWidget *vbox2; + +/* Use only PlaySound() on Windows, to be followed on Unix with libcanberra sometime. + * Till then, keep the related set variables on Windows to avoid losing settings when + * moving across platforms. + */ +#ifndef WIN32 GtkWidget *table2; GtkWidget *label2; GtkWidget *label3; GtkWidget *radio_external; GSList *radio_group = NULL; GtkWidget *radio_auto; +#endif GtkWidget *scrolledwindow1; GtkWidget *sound_tree; GtkWidget *table1; @@ -1712,6 +1725,7 @@ setup_create_sound_page (void) gtk_widget_show (vbox2); gtk_container_add (GTK_CONTAINER (vbox1), vbox2); +#ifndef WIN32 table2 = gtk_table_new (4, 3, FALSE); gtk_widget_show (table2); gtk_box_pack_start (GTK_BOX (vbox2), table2, FALSE, TRUE, 8); @@ -1766,6 +1780,7 @@ setup_create_sound_page (void) radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_auto)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_auto), setup_prefs.hex_sound_command[0] == 0); +#endif scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow1); @@ -1827,7 +1842,9 @@ setup_create_sound_page (void) (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); +#ifndef WIN32 gtk_label_set_mnemonic_widget (GTK_LABEL (label3), sndprog_entry); +#endif setup_snd_row_cb (sel, NULL); return vbox1; @@ -2279,7 +2296,9 @@ setup_apply_cb (GtkWidget *but, GtkWidget *win) static void setup_ok_cb (GtkWidget *but, GtkWidget *win) { +#ifndef WIN32 setup_snd_apply (); +#endif gtk_widget_destroy (win); setup_apply (&setup_prefs); save_config (); |