diff options
author | kotontrion <[email protected]> | 2024-05-23 16:03:04 +0200 |
---|---|---|
committer | kotontrion <[email protected]> | 2024-05-23 16:03:04 +0200 |
commit | f54981f20f6418848fa86fbd6d56642906ef0f17 (patch) | |
tree | aec13c058e33d2cc12c4cb4b8adb65279ab42300 /src/watcher.vala | |
parent | fc09b269240ed2716c7949b1f73133a9c01ae107 (diff) |
code formatting
Diffstat (limited to 'src/watcher.vala')
-rw-r--r-- | src/watcher.vala | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/src/watcher.vala b/src/watcher.vala index a7ba3d5..cf06c7d 100644 --- a/src/watcher.vala +++ b/src/watcher.vala @@ -1,68 +1,67 @@ namespace AstalTray { -[DBus (name="org.kde.StatusNotifierWatcher")] -internal class StatusNotifierWatcher : Object { + [DBus (name="org.kde.StatusNotifierWatcher")] + internal class StatusNotifierWatcher : Object { - private HashTable<string, string> _items; + private HashTable<string, string> _items; - public string[] RegisteredStatusNotifierItems { owned get { return _items.get_values_as_ptr_array().data; } } - public bool IsStatusNotifierHostRegistered { get; default = true; } - public int ProtocolVersion { get; default = 0; } + public string[] RegisteredStatusNotifierItems { owned get { return _items.get_values_as_ptr_array().data; } } + public bool IsStatusNotifierHostRegistered { get; default = true; } + public int ProtocolVersion { get; default = 0; } - public signal void StatusNotifierItemRegistered(string service); - public signal void StatusNotifierItemUnregistered(string service); - public signal void StatusNotifierHostRegistered(); - public signal void StatusNotifierHostUnregistered(); - - construct { - _items = new HashTable<string, string>(GLib.str_hash, GLib.str_equal); - } + public signal void StatusNotifierItemRegistered(string service); + public signal void StatusNotifierItemUnregistered(string service); + public signal void StatusNotifierHostRegistered(); + public signal void StatusNotifierHostUnregistered(); - public void RegisterStatusNotifierItem(string service, BusName sender) throws DBusError, IOError { - string busName; - string path; - if(service[0] == '/') { - path = service; - busName = sender; - } - else { - busName = service; - path = "/StatusNotifierItem"; + construct { + _items = new HashTable<string, string>(GLib.str_hash, GLib.str_equal); } - Bus.get_sync(BusType.SESSION).signal_subscribe( - null, - "org.freedesktop.DBus", - "NameOwnerChanged", - null, - null, - DBusSignalFlags.NONE, - (connection, sender_name, path, interface_name, signal_name, parameters) => { - string name = null; - string new_owner = null; - string old_owner = null; - parameters.get("(sss)", &name, &old_owner, &new_owner); - if(new_owner == "" && _items.contains(old_owner)){ - string full_path = _items.take(old_owner); - StatusNotifierItemUnregistered(full_path); - } + public void RegisterStatusNotifierItem(string service, BusName sender) throws DBusError, IOError { + string busName; + string path; + if(service[0] == '/') { + path = service; + busName = sender; + } + else { + busName = service; + path = "/StatusNotifierItem"; + } + + Bus.get_sync(BusType.SESSION).signal_subscribe( + null, + "org.freedesktop.DBus", + "NameOwnerChanged", + null, + null, + DBusSignalFlags.NONE, + (connection, sender_name, path, interface_name, signal_name, parameters) => { + string name = null; + string new_owner = null; + string old_owner = null; + parameters.get("(sss)", &name, &old_owner, &new_owner); + if(new_owner == "" && _items.contains(old_owner)){ + string full_path = _items.take(old_owner); + StatusNotifierItemUnregistered(full_path); } + } ); - _items.set(busName, busName+path); + _items.set(busName, busName+path); - StatusNotifierItemRegistered(busName+path); - } + StatusNotifierItemRegistered(busName+path); + } - public void RegisterStatusNotifierHost(string service) throws DBusError, IOError { - /* + public void RegisterStatusNotifierHost(string service) throws DBusError, IOError { + /* NOTE: usually the watcher should keep track of registered host but some tray applications do net register their trayitem properly when hosts register/deregister. This is fixed by setting isHostRegistered always to true, this also make host handling logic unneccessary. - */ + */ + } } - -} } |