Added GetSubscribeData to dbus daemon (#123)
* Added GetSubscribeData to dbus daemon * Updated client to use GetSubscribeData
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
public struct SwayncDaemonData {
|
||||
public bool dnd;
|
||||
public bool cc_open;
|
||||
public uint count;
|
||||
}
|
||||
|
||||
[DBus (name = "org.erikreider.swaync.cc")]
|
||||
interface CcDaemon : GLib.Object {
|
||||
|
||||
@@ -21,6 +27,9 @@ interface CcDaemon : GLib.Object {
|
||||
|
||||
public abstract void set_visibility (bool value) throws DBusError, IOError;
|
||||
|
||||
[DBus (name = "GetSubscribeData")]
|
||||
public abstract SwayncDaemonData get_subscribe_data () throws Error;
|
||||
|
||||
public signal void subscribe (uint count, bool dnd, bool cc_open);
|
||||
}
|
||||
|
||||
@@ -58,9 +67,8 @@ private void on_subscribe (uint count, bool dnd, bool cc_open) {
|
||||
|
||||
private void print_subscribe () {
|
||||
try {
|
||||
on_subscribe (cc_daemon.notification_count (),
|
||||
cc_daemon.get_dnd (),
|
||||
cc_daemon.get_visibility ());
|
||||
SwayncDaemonData data = cc_daemon.get_subscribe_data ();
|
||||
on_subscribe (data.count, data.dnd, data.cc_open);
|
||||
} catch (Error e) {
|
||||
on_subscribe (0, false, false);
|
||||
}
|
||||
@@ -86,9 +94,8 @@ private void on_subscribe_waybar (uint count, bool dnd, bool cc_open) {
|
||||
|
||||
private void print_subscribe_waybar () {
|
||||
try {
|
||||
on_subscribe_waybar (cc_daemon.notification_count (),
|
||||
cc_daemon.get_dnd (),
|
||||
cc_daemon.get_visibility ());
|
||||
SwayncDaemonData data = cc_daemon.get_subscribe_data ();
|
||||
on_subscribe_waybar (data.count, data.dnd, data.cc_open);
|
||||
} catch (Error e) {
|
||||
on_subscribe_waybar (0, false, false);
|
||||
}
|
||||
|
@@ -1,4 +1,10 @@
|
||||
namespace SwayNotificationCenter {
|
||||
public struct Data {
|
||||
public bool dnd;
|
||||
public bool cc_open;
|
||||
public uint count;
|
||||
}
|
||||
|
||||
[DBus (name = "org.erikreider.swaync.cc")]
|
||||
public class SwayncDaemon : Object {
|
||||
public StateCache cache_state;
|
||||
@@ -57,6 +63,16 @@ namespace SwayNotificationCenter {
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets subscribe data but in one call */
|
||||
[DBus (name = "GetSubscribeData")]
|
||||
public Data get_subscribe_data () throws Error {
|
||||
return Data () {
|
||||
dnd = get_dnd (),
|
||||
cc_open = get_visibility (),
|
||||
count = notification_count (),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when Dot Not Disturb state changes and when
|
||||
* notification gets added/removed
|
||||
|
Reference in New Issue
Block a user