LibNotifyLoader: implement generic HasCapability

This commit is contained in:
Marco Trevisan (Treviño) 2016-04-14 18:24:00 +02:00
parent 77ca9bc76e
commit 8dd7a8d7fe

View file

@ -17,6 +17,18 @@ namespace brightray {
namespace { namespace {
LibNotifyLoader libnotify_loader_; LibNotifyLoader libnotify_loader_;
bool HasCapability(const std::string& capability) {
bool result = false;
GList* capabilities = libnotify_loader_.notify_get_server_caps();
if (g_list_find_custom(capabilities, capability.c_str(), (GCompareFunc) g_strcmp0) != NULL)
result = true;
g_list_free_full(capabilities, g_free);
return result;
}
bool NotifierSupportsActions() { bool NotifierSupportsActions() {
if (getenv("ELECTRON_USE_UBUNTU_NOTIFIER")) if (getenv("ELECTRON_USE_UBUNTU_NOTIFIER"))
return false; return false;
@ -28,12 +40,7 @@ bool NotifierSupportsActions() {
if (notify_has_result) if (notify_has_result)
return notify_result; return notify_result;
capabilities = libnotify_loader_.notify_get_server_caps(); notify_result = HasCapability("actions");
if (g_list_find_custom(capabilities, "actions", (GCompareFunc) g_strcmp0) != NULL)
notify_result = true;
g_list_free_full(capabilities, g_free);
return notify_result; return notify_result;
} }