Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ public class Notifications.Application : Gtk.Application {
);
}

public static void play_sound (string sound_name) {
Canberra.Proplist props;
Canberra.Proplist.create (out props);

props.sets (Canberra.PROP_CANBERRA_CACHE_CONTROL, "volatile");
props.sets (Canberra.PROP_EVENT_ID, sound_name);

CanberraGtk4.context_get ().play_full (0, props);
}

public static int main (string[] args) {
var app = new Application ();
return app.run (args);
Expand Down
18 changes: 2 additions & 16 deletions src/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public class Notifications.Server : Object {
sound = category_to_sound_name (hints["category"].get_string ());
}

send_sound (sound);
Application.play_sound (sound);
}
}
}
Expand All @@ -196,7 +196,7 @@ public class Notifications.Server : Object {
// consistency it should. So we make it emit the default one.
var confirmation_type = hints.lookup (X_CANONICAL_PRIVATE_SYNCHRONOUS).get_string ();
if (confirmation_type == "indicator-sound") {
send_sound ("audio-volume-change");
Application.play_sound ("audio-volume-change");
}

if (confirmation == null) {
Expand All @@ -216,20 +216,6 @@ public class Notifications.Server : Object {
confirmation.present ();
}

private void send_sound (string sound_name) {
if (sound_name == "") {
return;
}

Canberra.Proplist props;
Canberra.Proplist.create (out props);

props.sets (Canberra.PROP_CANBERRA_CACHE_CONTROL, "volatile");
props.sets (Canberra.PROP_EVENT_ID, sound_name);

CanberraGtk4.context_get ().play_full (0, props);
}

static unowned string category_to_sound_name (string category) {
unowned string sound;

Expand Down