7
* Copyright (c) 2011 Emily Strickland <emily@zubon.org>
10
* Emily Strickland <emily@zubon.org>
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License
14
* as published by the Free Software Foundation; either version 2
15
* of the License, or (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
26
COMPIZ_PLUGIN_20090315 (bell, BellPluginVTable);
33
if ((error = ca_context_play (mCanberraContext, 0,
34
CA_PROP_EVENT_ID, "bell",
35
CA_PROP_MEDIA_FILENAME, mFilename.c_str (),
36
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
39
compLogMessage ("bell", CompLogLevelWarn, "couldn't play sound %s - %s",
40
mFilename.c_str (), ca_strerror (error));
43
/* Allow other plugins to handle bell event */
48
AudibleBell::filenameChange(CompOption *option,
53
mFilename = optionGetFilename();
55
if ((error = ca_context_change_props (mCanberraContext,
56
CA_PROP_APPLICATION_NAME, "Compiz bell",
57
CA_PROP_APPLICATION_ID, "org.freedesktop.compiz.Bell",
58
CA_PROP_WINDOW_X11_SCREEN, screen->displayString(),
61
compLogMessage ("bell", CompLogLevelWarn, "couldn't change context properties - %s",
65
if ((error = ca_context_cache (mCanberraContext,
66
CA_PROP_EVENT_ID, "bell",
67
CA_PROP_MEDIA_FILENAME, mFilename.c_str (),
68
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
71
compLogMessage ("bell", CompLogLevelWarn, "couldn't change context cache - %s",
77
AudibleBell::AudibleBell (CompScreen *screen) :
78
PluginClassHandler <AudibleBell, CompScreen> (screen),
79
mCanberraContext (NULL),
80
mFilename (optionGetFilename ())
83
boost::function <void (CompOption *, Options)> fileNameChangedCallback;
84
boost::function <bool (CompAction *, CompAction::State, CompOption::Vector &)> bellCallback;
86
if ((error = ca_context_create (&mCanberraContext)) < 0)
88
compLogMessage ("bell", CompLogLevelWarn, "couldn't initialize canberra - %s",
94
if ((error = ca_context_change_props (mCanberraContext,
95
CA_PROP_APPLICATION_NAME,
97
CA_PROP_APPLICATION_ID,
98
"org.freedesktop.compiz.Bell",
99
CA_PROP_WINDOW_X11_SCREEN,
100
screen->displayString (),
103
compLogMessage ("bell", CompLogLevelWarn, "couldn't register bell handler - %s",
104
ca_strerror (error));
109
if ((error = ca_context_open (mCanberraContext)) < 0)
111
compLogMessage ("bell", CompLogLevelWarn, "couldn't open canberra context - %s",
112
ca_strerror (error));
118
fileNameChangedCallback =
119
boost::bind (&AudibleBell::filenameChange, this, _1, _2);
121
boost::bind (&AudibleBell::bell, this);
123
optionSetFilenameNotify (fileNameChangedCallback);
124
optionSetBellInitiate (bellCallback);
127
AudibleBell::~AudibleBell ()
129
ca_context_destroy (mCanberraContext);
133
BellPluginVTable::init ()
135
if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))