~hypodermia/ubuntu/oneiric/compiz/fix-for-bug-301174

« back to all changes in this revision

Viewing changes to plugins/bell/src/bell.cpp

  • Committer: Emily Strickland
  • Date: 2011-08-07 06:43:17 UTC
  • Revision ID: emily@zubon.org-20110807064317-kzom6afwgvhdwqmn
Removed option to specify the file name. Should follow user's sound scheme.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "bell.h"
25
25
 
26
 
COMPIZ_PLUGIN_20090315 (bell, BellPluginVTable);
 
26
COMPIZ_PLUGIN_20090315 (bell, BellPluginVTable)
27
27
 
28
28
bool
29
29
AudibleBell::bell ()
31
31
    int error;
32
32
 
33
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",
37
 
                                  NULL)) < 0)
 
34
                              CA_PROP_EVENT_ID, "bell",
 
35
                              CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
 
36
                              NULL)) < 0);
38
37
    {
39
 
        compLogMessage ("bell", CompLogLevelWarn, "couldn't play sound %s - %s",
40
 
                        mFilename.c_str (), ca_strerror (error));
 
38
        compLogMessage ("bell", CompLogLevelWarn, "couldn't play bell - %s",
 
39
                    ca_strerror (error));
41
40
    }
42
41
 
43
42
    /* Allow other plugins to handle bell event */
44
43
    return false;
45
44
}
46
45
 
47
 
void
48
 
AudibleBell::filenameChange(CompOption *option,
49
 
                            Options    num)
50
 
{
51
 
    int         error;
52
 
 
53
 
    mFilename = optionGetFilename();
54
 
 
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(),
59
 
                                           NULL)) < 0)
60
 
    {
61
 
        compLogMessage ("bell", CompLogLevelWarn, "couldn't change context properties - %s",
62
 
                        ca_strerror (error));
63
 
    }
64
 
 
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",
69
 
                                   NULL)) < 0)
70
 
    {
71
 
        compLogMessage ("bell", CompLogLevelWarn, "couldn't change context cache - %s",
72
 
                        ca_strerror (error));
73
 
    }
74
 
}
75
 
 
76
 
 
77
46
AudibleBell::AudibleBell (CompScreen *screen) :
78
47
    PluginClassHandler <AudibleBell, CompScreen> (screen),
79
 
    mCanberraContext (NULL),
80
 
    mFilename (optionGetFilename ())
 
48
    mCanberraContext (NULL)
81
49
{
82
 
    int                                            error;
83
 
    boost::function <void (CompOption *, Options)> fileNameChangedCallback;
 
50
    int                        error;
84
51
    boost::function <bool (CompAction *, CompAction::State, CompOption::Vector &)> bellCallback;
85
52
 
86
53
    if ((error = ca_context_create (&mCanberraContext)) < 0)
115
82
        }
116
83
    }
117
84
 
118
 
    fileNameChangedCallback =
119
 
        boost::bind (&AudibleBell::filenameChange, this, _1, _2);
120
85
    bellCallback =
121
 
        boost::bind (&AudibleBell::bell, this);
 
86
    boost::bind (&AudibleBell::bell, this);
122
87
 
123
 
    optionSetFilenameNotify (fileNameChangedCallback);
124
88
    optionSetBellInitiate (bellCallback);
125
89
}
126
90