NotificationDaemon: support sound in notifications
The notifications spec has two hints for playing a sound, sound-file and sound-name. We can support them using the existing code that wraps libcanberra. https://bugzilla.gnome.org/show_bug.cgi?id=642831
This commit is contained in:
@ -1537,11 +1537,12 @@ shell_global_run_at_leisure (ShellGlobal *global,
|
||||
|
||||
static void
|
||||
build_ca_proplist_for_event (ca_proplist *props,
|
||||
const char *event_property,
|
||||
const char *event_id,
|
||||
const char *event_description,
|
||||
ClutterEvent *for_event)
|
||||
{
|
||||
ca_proplist_sets (props, CA_PROP_EVENT_ID, event_id);
|
||||
ca_proplist_sets (props, event_property, event_id);
|
||||
ca_proplist_sets (props, CA_PROP_EVENT_DESCRIPTION, event_description);
|
||||
ca_proplist_sets (props, CA_PROP_CANBERRA_CACHE_CONTROL, "volatile");
|
||||
|
||||
@ -1589,7 +1590,7 @@ shell_global_play_theme_sound (ShellGlobal *global,
|
||||
ca_proplist *props;
|
||||
|
||||
ca_proplist_create (&props);
|
||||
build_ca_proplist_for_event (props, name, description, for_event);
|
||||
build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
|
||||
|
||||
ca_context_play_full (global->sound_context, id, props, NULL, NULL);
|
||||
|
||||
@ -1621,7 +1622,7 @@ shell_global_play_theme_sound_full (ShellGlobal *global,
|
||||
ca_proplist *props;
|
||||
|
||||
ca_proplist_create (&props);
|
||||
build_ca_proplist_for_event (props, name, description, for_event);
|
||||
build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
|
||||
ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
|
||||
ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
|
||||
|
||||
@ -1630,6 +1631,68 @@ shell_global_play_theme_sound_full (ShellGlobal *global,
|
||||
ca_proplist_destroy (props);
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_global_play_sound_file_full:
|
||||
* @global: the #ShellGlobal
|
||||
* @id: an id, used to cancel later (0 if not needed)
|
||||
* @file_name: the file name to play
|
||||
* @description: the localized description of the event that triggered this alert
|
||||
* @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
|
||||
* @application_id: application on behalf of which the sound is played
|
||||
* @application_name:
|
||||
*
|
||||
* Like shell_global_play_theme_sound_full(), but with an explicit path
|
||||
* instead of a themed sound.
|
||||
*/
|
||||
void
|
||||
shell_global_play_sound_file_full (ShellGlobal *global,
|
||||
guint id,
|
||||
const char *file_name,
|
||||
const char *description,
|
||||
ClutterEvent *for_event,
|
||||
const char *application_id,
|
||||
const char *application_name)
|
||||
{
|
||||
ca_proplist *props;
|
||||
|
||||
ca_proplist_create (&props);
|
||||
build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
|
||||
ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
|
||||
ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
|
||||
|
||||
ca_context_play_full (global->sound_context, id, props, NULL, NULL);
|
||||
|
||||
ca_proplist_destroy (props);
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_global_play_sound_file:
|
||||
* @global: the #ShellGlobal
|
||||
* @id: an id, used to cancel later (0 if not needed)
|
||||
* @file_name: the file name to play
|
||||
* @description: the localized description of the event that triggered this alert
|
||||
* @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
|
||||
*
|
||||
* Like shell_global_play_theme_sound(), but with an explicit path
|
||||
* instead of a themed sound.
|
||||
*/
|
||||
void
|
||||
shell_global_play_sound_file (ShellGlobal *global,
|
||||
guint id,
|
||||
const char *file_name,
|
||||
const char *description,
|
||||
ClutterEvent *for_event)
|
||||
{
|
||||
ca_proplist *props;
|
||||
|
||||
ca_proplist_create (&props);
|
||||
build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
|
||||
|
||||
ca_context_play_full (global->sound_context, id, props, NULL, NULL);
|
||||
|
||||
ca_proplist_destroy (props);
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_global_cancel_theme_sound:
|
||||
* @global: the #ShellGlobal
|
||||
|
Reference in New Issue
Block a user