Added sound manager; see issue #424; cmake and rebuild req.

This commit is contained in:
Oliver Duis
2010-12-20 16:18:12 +01:00
parent c3b99f5f48
commit 8ce5683f6c
9 changed files with 130 additions and 4 deletions

View File

@@ -506,12 +506,15 @@ PREFERENCES_SHOWONLYRAW;Show only RAW files
PREFERENCES_SHTHRESHOLD;Threshold for clipped shadows
PREFERENCES_SINGLETAB;Single tab mode
PREFERENCES_SINGLETABVERTAB;Single tab mode, vertical tabs
PREFERENCES_SND_BATCHQUEUEDONE;Batch queue done
PREFERENCES_SND_HELP;Either enter filepath or nothing (for no sound). On Windows use "SystemDefault", "SystemAsterisk" etc. for system sounds.
PREFERENCES_STARTUPIMDIR;Image directory at startup
PREFERENCES_TAB_BROWSER;File Browser
PREFERENCES_TAB_COLORMGR;Color Management
PREFERENCES_TAB_GENERAL;General
PREFERENCES_TAB_IMPROC;Image Processing
PREFERENCES_TAB_OUTPUT;Output Options
PREFERENCES_TAB_SOUND;Sounds
PREFERENCES_THUMBSIZE;Thumbnail Size
PREFERENCES_USESYSTEMTHEME; Use System Theme
PREFERENCES_WORKFLOW;Workflow

View File

@@ -19,7 +19,7 @@ set (BASESOURCEFILES
imageareapanel.cc iptcpanel.cc labcurve.cc lumadenoise.cc main.cc
multilangmgr.cc mycurve.cc options.cc
preferences.cc profilepanel.cc saveasdlg.cc
saveformatpanel.cc splash.cc
saveformatpanel.cc soundman.cc splash.cc
thumbnail.cc tonecurve.cc toolbar.cc
guiutils.cc zoompanel.cc toolpanelcoord.cc
thumbbrowserentrybase.cc batchqueueentry.cc
@@ -31,6 +31,7 @@ set (BASESOURCEFILES
if (WIN32)
set (EXTRA_SRC windirmonitor.cc myicon.o)
set (EXTRA_LIB_RTGUI winmm)
include_directories ( ../rtengine ${CMAKE_CURRENT_BINARY_DIR} . ../rtexif ${EXTRA_INCDIR} ${GLIB2_INCLUDE_DIRS} ${GLIBMM_INCLUDE_DIRS}
${GTK_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS} ${GIO_INCLUDE_DIRS} ${GIOMM_INCLUDE_DIRS})
link_directories (. ../rtexif ${EXTRA_LIBDIR} ${GLIB2_LIBRARY_DIRS} ${GLIBMM_LIBRARY_DIRS}
@@ -51,6 +52,6 @@ set_target_properties (rth PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" OUTPUT_
#target_link_libraries (rth rtengine ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${TIFF_LIBRARIES} ${EXTRA_LIB} ${GOBJECT_LIBRARIES} ${GTHREAD_LIBRARIES}
# ${GLIB2_LIBRARIES} ${GLIBMM_LIBRARIES} ${GTK_LIBRARIES} ${GTKMM_LIBRARIES} ${GIO_LIBRARIES} ${GIOMM_LIBRARIES} ${LCMS_LIBRARIES} ${IPTCDATA_LIBRARIES})
target_link_libraries (rth rtengine ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${TIFF_LIBRARIES} ${GOBJECT_LIBRARIES} ${GTHREAD_LIBRARIES}
${GLIB2_LIBRARIES} ${GLIBMM_LIBRARIES} ${GTK_LIBRARIES} ${GTKMM_LIBRARIES} ${GIO_LIBRARIES} ${GIOMM_LIBRARIES} ${LCMS_LIBRARIES} ${IPTCDATA_LIBRARIES})
${GLIB2_LIBRARIES} ${GLIBMM_LIBRARIES} ${GTK_LIBRARIES} ${GTKMM_LIBRARIES} ${GIO_LIBRARIES} ${GIOMM_LIBRARIES} ${LCMS_LIBRARIES} ${IPTCDATA_LIBRARIES} ${EXTRA_LIB_RTGUI})
install (TARGETS rth DESTINATION ${BINDIR})

View File

@@ -21,7 +21,8 @@
#include <preferences.h>
#include <multilangmgr.h>
#include <rtwindow.h>
#include <safegtk.h>
#include <soundman.h>
BatchQueuePanel::BatchQueuePanel () {
@@ -260,6 +261,8 @@ void BatchQueuePanel::queueEmpty () {
stopBatchProc ();
fdir->set_sensitive (true);
fformat->set_sensitive (true);
SoundManager::playSoundAsync(options.sndBatchQueueDone);
}
bool BatchQueuePanel::canStartNext () {

View File

@@ -296,6 +296,10 @@ if (keyFile.has_group ("Batch Processing")) {
if (keyFile.has_key ("Batch Processing", "AdjusterBehavior")) baBehav = keyFile.get_integer_list ("Batch Processing", "AdjusterBehavior");
}
if (keyFile.has_group ("Sounds")) {
if (keyFile.has_key ("Sounds", "BatchQueueDone")) sndBatchQueueDone = keyFile.get_string ("Sounds", "BatchQueueDone");
}
return 0;
}
@@ -424,6 +428,8 @@ int Options::saveToFile (Glib::ustring fname) {
Glib::ArrayHandle<int> bab = baBehav;
keyFile.set_integer_list ("Batch Processing", "AdjusterBehavior", bab);
keyFile.set_string ("Sounds", "BatchQueueDone", sndBatchQueueDone);
FILE *f = safe_g_fopen (fname, "wt");
if (f==NULL)

View File

@@ -136,6 +136,9 @@ class Options {
int multiDisplayMode; // 0=none, 1=Edit panels on other display
std::vector<double> cutOverlayBrush; // Red;Green;Blue;Alpha , all ranging 0..1
Glib::ustring sndBatchQueueDone;
Options ();
Options* copyFrom (Options* other);

View File

@@ -1,7 +1,7 @@
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>, Oliver Duis <www.oliverduis.de>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -81,6 +81,7 @@ 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"));
nb->append_page (*getSoundPanel(), M("PREFERENCES_TAB_SOUND"));
nb->set_current_page (0);
fillPreferences ();
@@ -673,6 +674,27 @@ Gtk::Widget* Preferences::getFileBrowserPanel () {
return mvbfb;
}
Gtk::Widget* Preferences::getSoundPanel () {
Gtk::VBox* pSnd = new Gtk::VBox ();
Gtk::Label* lSndHelp = Gtk::manage (new Gtk::Label (M("PREFERENCES_SND_HELP")));
pSnd->pack_start (*lSndHelp, Gtk::PACK_SHRINK, 4);
Gtk::HBox* pBatchQueueDone = new Gtk::HBox();
Gtk::Label* lSndBatchQueueDone = Gtk::manage (new Gtk::Label (M("PREFERENCES_SND_BATCHQUEUEDONE") + Glib::ustring(":")));
pBatchQueueDone->pack_start (*lSndBatchQueueDone, Gtk::PACK_SHRINK, 12);
txtSndBatchQueueDone = Gtk::manage (new Gtk::Entry());
pBatchQueueDone->pack_end (*txtSndBatchQueueDone, Gtk::PACK_EXPAND_WIDGET, 4);
pSnd->pack_start (*pBatchQueueDone, Gtk::PACK_SHRINK, 4);
pSnd->set_border_width (4);
return pSnd;
}
void Preferences::parseDir (Glib::ustring dirname, std::vector<Glib::ustring>& items, Glib::ustring ext) {
// process directory
@@ -787,6 +809,8 @@ void Preferences::storePreferences () {
moptions.mainNBVertical = editorMode==1;
moptions.overwriteOutputFile = chOverwriteOutputFile->get_active ();
moptions.sndBatchQueueDone = txtSndBatchQueueDone->get_text ();
}
void Preferences::fillPreferences () {
@@ -892,6 +916,8 @@ void Preferences::fillPreferences () {
dfconn.block (false);
chOverwriteOutputFile->set_active (moptions.overwriteOutputFile);
txtSndBatchQueueDone->set_text (moptions.sndBatchQueueDone);
}
/*

View File

@@ -107,6 +107,8 @@ class Preferences : public Gtk::Dialog {
Gtk::ComboBoxText* editorLayout;
RTWindow* parent;
Gtk::Entry* txtSndBatchQueueDone;
Options moptions;
sigc::connection tconn, fconn, usethcon, addc, setc, dfconn;
Glib::ustring initialTheme;
@@ -130,6 +132,7 @@ class Preferences : public Gtk::Dialog {
Gtk::Widget* getFileBrowserPanel ();
Gtk::Widget* getGeneralPanel ();
Gtk::Widget* getBatchProcPanel ();
Gtk::Widget* getSoundPanel ();
public:
Preferences (RTWindow *rtwindow);

50
rtgui/soundman.cc Normal file
View File

@@ -0,0 +1,50 @@
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2010 Oliver Duis <www.oliverduis.de>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <soundman.h>
#ifdef WIN32
#include <windows.h>
#include <mmsystem.h>
#endif
// Plays a sound in async mode to not block the main thread
// 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 (sound.empty()) return;
#ifdef WIN32
DWORD sndParam=SND_ASYNC | SND_NODEFAULT;
if (sound.find('.')!=Glib::ustring::npos) {
// contain dot, so it's a filename
sndParam|=SND_FILENAME;
} else {
// no dot, so it's a system event
sndParam|=SND_ALIAS;
}
PlaySound(safe_filename_from_utf8(sound).c_str(), NULL, sndParam);
#else
// TODO: Add code for other OSes here
printf("Sound not supported on your OS (yet)\n");
#endif
}

31
rtgui/soundman.h Normal file
View File

@@ -0,0 +1,31 @@
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2010 Oliver Duis <www.oliverduis.de>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _SOUNDMAN_
#define _SOUNDMAN_
#include <safegtk.h>
class SoundManager {
public:
static void playSoundAsync(const Glib::ustring &sound);
};
#endif