Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notifications: Toggle Do Not Disturb state when middle-clicking the applet icon #677

Merged
merged 2 commits into from
Mar 2, 2025
Merged
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
41 changes: 25 additions & 16 deletions src/panel/applets/notifications/NotificationsApplet.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public interface RavenRemote : GLib.Object {

[DBus (name="org.buddiesofbudgie.budgie.Dispatcher")]
public interface DispatcherRemote : GLib.Object {
public abstract void toggle_do_not_disturb() throws DBusError, IOError;
public signal void DoNotDisturbChanged(bool value);
}

Expand Down Expand Up @@ -141,23 +142,31 @@ public class NotificationsApplet : Budgie.Applet {
}

bool on_button_release(Gdk.EventButton? button) {
if (raven_proxy == null) {
return Gdk.EVENT_PROPAGATE;
if (raven_proxy == null) return Gdk.EVENT_PROPAGATE;
if (dispatcher == null) return Gdk.EVENT_PROPAGATE;

switch (button.button) {
case Gdk.BUTTON_PRIMARY:
raven_proxy.ToggleNotificationsView.begin((obj,res) => {
try {
raven_proxy.ToggleNotificationsView.end(res);
} catch (Error e) {
warning("Failed to toggle Raven: %s", e.message);
}
});

return Gdk.EVENT_STOP;
case Gdk.BUTTON_MIDDLE:
try {
dispatcher.toggle_do_not_disturb();
} catch (Error e) {
warning("Failed to toggle DoNotDisturb state: %s", e.message);
}

return Gdk.EVENT_STOP;
default:
return Gdk.EVENT_PROPAGATE;
}

if (button.button != 1) {
return Gdk.EVENT_PROPAGATE;
}

raven_proxy.ToggleNotificationsView.begin((obj,res) => {
try {
raven_proxy.ToggleNotificationsView.end(res);
} catch (Error e) {
message("Failed to toggle Raven: %s", e.message);
}
});

return Gdk.EVENT_STOP;
}
}

Expand Down