diff options
| author | Drew DeVault <sir@cmpwn.com> | 2017-12-29 14:24:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-29 14:24:23 -0500 |
| commit | 1e87c90923eef75b7d032322dfef38def944c2bb (patch) | |
| tree | ed17f848e7ac95c919d23424671a8a8ad5651a86 /include | |
| parent | d85ad05fa857cd7d7af2c8e2c33616d7895e1955 (diff) | |
| parent | 4d34bc393e7b144fbc105537f17bee329c44814d (diff) | |
Merge pull request #1431 from 4e554c4c/sni_sucks
Support libappindicator
Diffstat (limited to 'include')
| -rw-r--r-- | include/swaybar/bar.h | 4 | ||||
| -rw-r--r-- | include/swaybar/tray/dbus.h | 31 | ||||
| -rw-r--r-- | include/swaybar/tray/sni.h | 19 |
3 files changed, 54 insertions, 0 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 50d36e76..7ec09e3e 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -21,6 +21,7 @@ struct bar { struct output { struct window *window; struct registry *registry; + struct output_state *state; list_t *workspaces; #ifdef ENABLE_TRAY list_t *items; @@ -28,6 +29,9 @@ struct output { char *name; int idx; bool focused; +#ifdef ENABLE_TRAY + bool active; +#endif }; struct workspace { 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 @@ #include <dbus/dbus.h> extern DBusConnection *conn; +enum property_status { + PROP_EXISTS, /* Will give iter */ + PROP_ERROR, /* Will not give iter */ + PROP_BAD_DATA, /* Will not give iter */ + PROP_WRONG_SIG, /* Will give iter, please be careful */ +}; + +/** + * Checks the signature of the given iter against `sig`. Prefer to + * `dbus_message_iter_get_signature` as this one frees the intermediate string. + */ +bool dbus_message_iter_check_signature(DBusMessageIter *iter, const char *sig); + +/** + * Fetches the property and calls `callback` with a message iter pointing it. + * Performs error handling and signature checking. + * + * Returns: true if message is successfully sent and false otherwise. If there + * is an error getting a property, `callback` will still be run, but with + * `status` set to the error. + * + * NOTE: `expected_signature` must remain valid until the message reply is + * received, please only use 'static signatures. + */ +bool dbus_get_prop_async(const char *destination, + const char *path, + const char *iface, + const char *prop, + const char *expected_signature, + void(*callback)(DBusMessageIter *iter, void *data, enum property_status status), + void *data); /** * Should be called in main loop to dispatch events */ 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 { char *name; /* Unique bus name, needed for determining signal origins */ char *unique_name; + /* Object path, useful for items not registerd by well known name */ + char *object_path; bool kde_special_snowflake; cairo_surface_t *image; @@ -31,6 +33,12 @@ void sni_icon_ref_free(struct sni_icon_ref *sni_ref); * May return `NULL` if `name` is not valid. */ struct StatusNotifierItem *sni_create(const char *name); +/** + * Same as sni_create, but takes an object path and unique name instead of + * well-known name. + */ +struct StatusNotifierItem *sni_create_from_obj_path(const char *unique_name, + const char *object_path); /** * `item` must be a struct StatusNotifierItem * @@ -46,6 +54,17 @@ int sni_str_cmp(const void *item, const void *str); */ int sni_uniq_cmp(const void *item, const void *str); + +struct ObjName { + const void *obj_path; + const void *name; +}; +/** + * Returns 0 if `item` has a name of `obj_name->name` and object path of + * `obj_name->obj_path`. + */ +int sni_obj_name_cmp(const void *item, const void *obj_name); + /** * Gets an icon for the given item if found. * |
