Second (and last) stage of adding sound notifications on Linux (see issue 469)

This commit is contained in:
Philip Rinn
2013-02-02 19:07:07 +01:00
parent a08e04626b
commit a112890cb9
4 changed files with 16 additions and 17 deletions

View File

@@ -790,7 +790,7 @@ PREFERENCES_SINGLETABVERTAB;Single Editor Tab Mode, Vertical Tabs
PREFERENCES_SINGLETAB;Single Editor Tab Mode
PREFERENCES_SLIMUI;Slim interface
PREFERENCES_SND_BATCHQUEUEDONE;Queue processing done
PREFERENCES_SND_HELP;Either enter filepath or nothing (for no sound). On Windows use "SystemDefault", "SystemAsterisk" etc. for system sounds.
PREFERENCES_SND_HELP;Either enter filepath or nothing (for no sound).\nOn Windows use "SystemDefault", "SystemAsterisk" etc. for system sounds.\nOn Linux use "complete", "window-attention" etc. for system sounds.
PREFERENCES_SND_LNGEDITPROCDONE;Editor processing done
PREFERENCES_SND_TRESHOLDSECS;after secs
PREFERENCES_SQUAREDETAILWINDOW;Square detail window (faster)

View File

@@ -348,12 +348,12 @@ void Options::setDefaults () {
cutOverlayBrush = std::vector<double> (4);
cutOverlayBrush[3] = 0.667; // :-p
#if defined(__linux__) || defined(WIN32)
sndEnable=true;
#else
sndEnable=false;
#endif
sndLngEditProcDoneSecs=3.0;
#ifdef __linux__
sndBatchQueueDone = "complete";
sndLngEditProcDone = "window-attention";
#endif
// Reminder: 0 = SET mode, 1 = ADD mode
int babehav[] = {

View File

@@ -82,7 +82,10 @@ Preferences::Preferences (RTWindow *rtwindow):parent(rtwindow) {
nb->append_page (*getFileBrowserPanel(), M("PREFERENCES_TAB_BROWSER"));
nb->append_page (*getColorManagementPanel(),M("PREFERENCES_TAB_COLORMGR"));
nb->append_page (*getBatchProcPanel(), M("PREFERENCES_BATCH_PROCESSING"));
// Sounds only on Windows and Linux
#if defined(WIN32) || defined(__linux__)
nb->append_page (*getSoundPanel(), M("PREFERENCES_TAB_SOUND"));
#endif
nb->set_current_page (0);
fillPreferences ();
@@ -1131,11 +1134,13 @@ void Preferences::storePreferences () {
moptions.overwriteOutputFile = chOverwriteOutputFile->get_active ();
moptions.UseIconNoText = ckbUseIconNoText->get_active();
// Sounds
// Sounds only on Windows and Linux
#if defined(WIN32) || defined(__linux__)
moptions.sndEnable = ckbSndEnable->get_active ();
moptions.sndBatchQueueDone = txtSndBatchQueueDone->get_text ();
moptions.sndLngEditProcDone = txtSndLngEditProcDone->get_text ();
moptions.sndLngEditProcDoneSecs = spbSndLngEditProcDoneSecs->get_value ();
#endif
}
void Preferences::fillPreferences () {
@@ -1276,15 +1281,13 @@ void Preferences::fillPreferences () {
chOverwriteOutputFile->set_active (moptions.overwriteOutputFile);
// Sounds
// Sounds only on Windows and Linux
#if defined(WIN32) || defined(__linux__)
ckbSndEnable->set_active (moptions.sndEnable);
txtSndBatchQueueDone->set_text (moptions.sndBatchQueueDone);
txtSndLngEditProcDone->set_text (moptions.sndLngEditProcDone);
#if defined(__linux__) || defined(__APPLE__)
txtSndBatchQueueDone->set_sensitive (false);
txtSndLngEditProcDone->set_sensitive (false);
#endif
spbSndLngEditProcDoneSecs->set_value (moptions.sndLngEditProcDoneSecs);
#endif
}
/*
@@ -1311,12 +1314,9 @@ void Preferences::autocielabToggled () {
}
*/
void Preferences::sndEnableToggled () {
#ifdef WIN32
txtSndBatchQueueDone->set_sensitive(ckbSndEnable->get_active());
txtSndLngEditProcDone->set_sensitive(ckbSndEnable->get_active());
#elif defined(__linux__) || defined(WIN32)
spbSndLngEditProcDoneSecs->set_sensitive(ckbSndEnable->get_active());
#endif
}
void Preferences::langAutoDetectToggled () {

View File

@@ -49,10 +49,9 @@ void SoundManager::init()
// param is either file name or name of the system event on Windows (e.g. "SystemAsterisk" or "SystemDefault").
void SoundManager::playSoundAsync(const Glib::ustring &sound)
{
if (!options.sndEnable) return;
if (sound.empty() || !options.sndEnable) return;
#ifdef WIN32
if (sound.empty()) return;
DWORD sndParam=SND_ASYNC | SND_NODEFAULT;
if (sound.find('.')!=Glib::ustring::npos) {
@@ -67,6 +66,6 @@ void SoundManager::playSoundAsync(const Glib::ustring &sound)
PlaySoundW(wfilename, NULL, sndParam);
g_free( wfilename );
#elif defined(__linux__)
ca_context_play(ca_gtk_context_get(), 0, CA_PROP_EVENT_ID, "complete", NULL);
ca_context_play(ca_gtk_context_get(), 0, CA_PROP_EVENT_ID, sound.c_str(), CA_PROP_MEDIA_FILENAME, sound.c_str(), NULL);
#endif
}