mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
gnotification: Add g_notification_set_sound
This commit is contained in:
parent
8a96fca390
commit
29fe398911
@ -242,6 +242,8 @@ call_notify (GDBusConnection *con,
|
||||
GVariant *parameters;
|
||||
const gchar *body;
|
||||
guchar urgency;
|
||||
const char *sound_name = NULL;
|
||||
GNotificationSound sound;
|
||||
|
||||
g_variant_builder_init (&action_builder, G_VARIANT_TYPE_STRING_ARRAY);
|
||||
if (g_notification_get_default_action (notification, NULL, NULL))
|
||||
@ -305,6 +307,25 @@ call_notify (GDBusConnection *con,
|
||||
}
|
||||
}
|
||||
|
||||
sound = g_notification_get_sound (notification);
|
||||
switch (sound)
|
||||
{
|
||||
case G_NOTIFICATION_SOUND_NONE:
|
||||
case G_NOTIFICATION_SOUND_DEFAULT:
|
||||
break;
|
||||
case G_NOTIFICATION_SOUND_NEW_MESSAGE:
|
||||
sound_name = "message-new-instant";
|
||||
break;
|
||||
default:
|
||||
g_debug ("Unknown sound set on notification %d", sound);
|
||||
}
|
||||
|
||||
if (sound_name != NULL)
|
||||
g_variant_builder_add (&hints_builder, "{sv}", "sound-name", g_variant_new_string (sound_name));
|
||||
|
||||
if (sound == G_NOTIFICATION_SOUND_NONE)
|
||||
g_variant_builder_add (&hints_builder, "{sv}", "suppress-sound", g_variant_new_boolean (TRUE));
|
||||
|
||||
body = g_notification_get_body (notification);
|
||||
|
||||
parameters = g_variant_new ("(susssasa{sv}i)",
|
||||
|
@ -1886,6 +1886,23 @@ typedef enum {
|
||||
G_NOTIFICATION_PRIORITY_URGENT
|
||||
} GNotificationPriority;
|
||||
|
||||
/**
|
||||
* GNotificationSound:
|
||||
* @G_NOTIFICATION_SOUND_DEFAULT: The default behavior of the platform which may or may not have a sound.
|
||||
* @G_NOTIFICATION_SOUND_NONE: Sounds will be surpressed if possible. Useful if playing own sounds.
|
||||
* @G_NOTIFICATION_SOUND_NEW_MESSAGE: A sound for new messages.
|
||||
*
|
||||
* Sounds used for #GNotifications. The actual sounds they represent
|
||||
* are backend defined.
|
||||
*
|
||||
* Since: 2.60
|
||||
*/
|
||||
typedef enum {
|
||||
G_NOTIFICATION_SOUND_DEFAULT,
|
||||
G_NOTIFICATION_SOUND_NONE,
|
||||
G_NOTIFICATION_SOUND_NEW_MESSAGE,
|
||||
} GNotificationSound;
|
||||
|
||||
/**
|
||||
* GNetworkConnectivity:
|
||||
* @G_NETWORK_CONNECTIVITY_LOCAL: The host is not configured with a
|
||||
|
@ -30,6 +30,8 @@ const gchar * g_notification_get_body (GNotifi
|
||||
|
||||
GIcon * g_notification_get_icon (GNotification *notification);
|
||||
|
||||
GNotificationSound g_notification_get_sound (GNotification *notification);
|
||||
|
||||
GNotificationPriority g_notification_get_priority (GNotification *notification);
|
||||
|
||||
guint g_notification_get_n_buttons (GNotification *notification);
|
||||
|
@ -77,6 +77,7 @@ struct _GNotification
|
||||
GPtrArray *buttons;
|
||||
gchar *default_action;
|
||||
GVariant *default_action_target;
|
||||
GNotificationSound sound;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@ -265,6 +266,24 @@ g_notification_get_icon (GNotification *notification)
|
||||
return notification->icon;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* g_notification_get_sound:
|
||||
* @notification: a #GNotification
|
||||
*
|
||||
* Gets the sound currently set on @notification.
|
||||
*
|
||||
* Returns: the sound associated with @notification
|
||||
*
|
||||
* Since: 2.60
|
||||
*/
|
||||
GNotificationSound
|
||||
g_notification_get_sound (GNotification *notification)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_NOTIFICATION (notification), G_NOTIFICATION_SOUND_DEFAULT);
|
||||
|
||||
return notification->sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_notification_set_icon:
|
||||
* @notification: a #GNotification
|
||||
@ -286,6 +305,25 @@ g_notification_set_icon (GNotification *notification,
|
||||
notification->icon = g_object_ref (icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_notification_set_sound:
|
||||
* @notification: a #GNotification
|
||||
* @sound: a sound to be shown with the @notification
|
||||
*
|
||||
* Sets the sound of @notification. The result of this sound
|
||||
* depends upon the backend and notification service used.
|
||||
*
|
||||
* Since: 2.60
|
||||
*/
|
||||
void
|
||||
g_notification_set_sound (GNotification *notification,
|
||||
GNotificationSound sound)
|
||||
{
|
||||
g_return_if_fail (G_IS_NOTIFICATION (notification));
|
||||
|
||||
notification->sound = sound;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* g_notification_get_priority:
|
||||
* @notification: a #GNotification
|
||||
|
@ -51,6 +51,10 @@ GLIB_AVAILABLE_IN_2_40
|
||||
void g_notification_set_icon (GNotification *notification,
|
||||
GIcon *icon);
|
||||
|
||||
GLIB_AVAILABLE_IN_2_60
|
||||
void g_notification_set_sound (GNotification *notification,
|
||||
GNotificationSound sound);
|
||||
|
||||
GLIB_DEPRECATED_IN_2_42_FOR(g_notification_set_priority)
|
||||
void g_notification_set_urgent (GNotification *notification,
|
||||
gboolean urgent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user