From 3357dc0ef76435576cd94ca76bbc9fc95b8da548 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Mon, 20 Apr 2015 13:22:18 -0700 Subject: [PATCH] Set icon for notification, and disable action on Ubuntu --- .../linux/notification_presenter_linux.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/brightray/browser/linux/notification_presenter_linux.cc b/brightray/browser/linux/notification_presenter_linux.cc index 45c5c7d9f6b3..88f0dcef9d5d 100644 --- a/brightray/browser/linux/notification_presenter_linux.cc +++ b/brightray/browser/linux/notification_presenter_linux.cc @@ -8,10 +8,13 @@ #include "base/bind.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" #include "content/public/browser/desktop_notification_delegate.h" #include "content/public/common/platform_notification_data.h" #include "common/application_info.h" +#include + namespace brightray { namespace { @@ -63,8 +66,20 @@ void NotificationPresenterLinux::ShowNotification( g_object_set_data_full(G_OBJECT(notification), "delegate", delegate, operator delete); g_signal_connect(notification, "closed", G_CALLBACK(OnNotificationClosedThunk), this); - notify_notification_add_action(notification, "default", "View", OnNotificationViewThunk, this, - nullptr); + + // NB: On Unity, adding a notification action will cause the notification + // to display as a modal dialog box. Testing for distros that have "Unity + // Zen Nature" is difficult, we will test for the presence of libindicate, + // an Unity-only library. + struct stat dontcare; + if (stat("/usr/lib/libindicate.so", &dontcare)) { + notify_notification_add_action(notification, "default", "View", OnNotificationViewThunk, this, nullptr); + } + + GdkPixbuf* pixbuf = libgtk2ui::GdkPixbufFromSkBitmap(icon); + + notify_notification_set_image_from_pixbuf(notification, pixbuf); + notify_notification_set_timeout(notification, NOTIFY_EXPIRES_DEFAULT); GError* error = nullptr; notify_notification_show(notification, &error);