diff options
Diffstat (limited to 'include/swaybar/tray')
-rw-r--r-- | include/swaybar/tray/dbus.h | 31 | ||||
-rw-r--r-- | include/swaybar/tray/sni.h | 19 |
2 files changed, 50 insertions, 0 deletions
diff --git a/include/swaybar/tray/dbus.h b/include/swaybar/tray/dbus.h index eb9cfea7..c693e6f7 100644 --- a/include/swaybar/tray/dbus.h +++ b/include/swaybar/tray/dbus.h | |||
@@ -5,6 +5,37 @@ | |||
5 | #include <dbus/dbus.h> | 5 | #include <dbus/dbus.h> |
6 | extern DBusConnection *conn; | 6 | extern DBusConnection *conn; |
7 | 7 | ||
8 | enum property_status { | ||
9 | PROP_EXISTS, /* Will give iter */ | ||
10 | PROP_ERROR, /* Will not give iter */ | ||
11 | PROP_BAD_DATA, /* Will not give iter */ | ||
12 | PROP_WRONG_SIG, /* Will give iter, please be careful */ | ||
13 | }; | ||
14 | |||
15 | /** | ||
16 | * Checks the signature of the given iter against `sig`. Prefer to | ||
17 | * `dbus_message_iter_get_signature` as this one frees the intermediate string. | ||
18 | */ | ||
19 | bool dbus_message_iter_check_signature(DBusMessageIter *iter, const char *sig); | ||
20 | |||
21 | /** | ||
22 | * Fetches the property and calls `callback` with a message iter pointing it. | ||
23 | * Performs error handling and signature checking. | ||
24 | * | ||
25 | * Returns: true if message is successfully sent and false otherwise. If there | ||
26 | * is an error getting a property, `callback` will still be run, but with | ||
27 | * `status` set to the error. | ||
28 | * | ||
29 | * NOTE: `expected_signature` must remain valid until the message reply is | ||
30 | * received, please only use 'static signatures. | ||
31 | */ | ||
32 | bool dbus_get_prop_async(const char *destination, | ||
33 | const char *path, | ||
34 | const char *iface, | ||
35 | const char *prop, | ||
36 | const char *expected_signature, | ||
37 | void(*callback)(DBusMessageIter *iter, void *data, enum property_status status), | ||
38 | void *data); | ||
8 | /** | 39 | /** |
9 | * Should be called in main loop to dispatch events | 40 | * Should be called in main loop to dispatch events |
10 | */ | 41 | */ |
diff --git a/include/swaybar/tray/sni.h b/include/swaybar/tray/sni.h index c2544e2a..95c10b9f 100644 --- a/include/swaybar/tray/sni.h +++ b/include/swaybar/tray/sni.h | |||
@@ -9,6 +9,8 @@ struct StatusNotifierItem { | |||
9 | char *name; | 9 | char *name; |
10 | /* Unique bus name, needed for determining signal origins */ | 10 | /* Unique bus name, needed for determining signal origins */ |
11 | char *unique_name; | 11 | char *unique_name; |
12 | /* Object path, useful for items not registerd by well known name */ | ||
13 | char *object_path; | ||
12 | bool kde_special_snowflake; | 14 | bool kde_special_snowflake; |
13 | 15 | ||
14 | cairo_surface_t *image; | 16 | cairo_surface_t *image; |
@@ -31,6 +33,12 @@ void sni_icon_ref_free(struct sni_icon_ref *sni_ref); | |||
31 | * May return `NULL` if `name` is not valid. | 33 | * May return `NULL` if `name` is not valid. |
32 | */ | 34 | */ |
33 | struct StatusNotifierItem *sni_create(const char *name); | 35 | struct StatusNotifierItem *sni_create(const char *name); |
36 | /** | ||
37 | * Same as sni_create, but takes an object path and unique name instead of | ||
38 | * well-known name. | ||
39 | */ | ||
40 | struct StatusNotifierItem *sni_create_from_obj_path(const char *unique_name, | ||
41 | const char *object_path); | ||
34 | 42 | ||
35 | /** | 43 | /** |
36 | * `item` must be a struct StatusNotifierItem * | 44 | * `item` must be a struct StatusNotifierItem * |
@@ -46,6 +54,17 @@ int sni_str_cmp(const void *item, const void *str); | |||
46 | */ | 54 | */ |
47 | int sni_uniq_cmp(const void *item, const void *str); | 55 | int sni_uniq_cmp(const void *item, const void *str); |
48 | 56 | ||
57 | |||
58 | struct ObjName { | ||
59 | const void *obj_path; | ||
60 | const void *name; | ||
61 | }; | ||
62 | /** | ||
63 | * Returns 0 if `item` has a name of `obj_name->name` and object path of | ||
64 | * `obj_name->obj_path`. | ||
65 | */ | ||
66 | int sni_obj_name_cmp(const void *item, const void *obj_name); | ||
67 | |||
49 | /** | 68 | /** |
50 | * Gets an icon for the given item if found. | 69 | * Gets an icon for the given item if found. |
51 | * | 70 | * |