aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-02-27 11:13:08 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-02-27 11:13:08 -0500
commite365214c51f8673feb293c8175c87c92672666b9 (patch)
tree27a1c0f2eb26e0304910e9f6ca2f5cb0b0299e50
parenta0d9eadc2ad022dc00af7fb7fb1f055cef79108c (diff)
downloadayatana-indicator-datetime-e365214c51f8673feb293c8175c87c92672666b9.tar.gz
ayatana-indicator-datetime-e365214c51f8673feb293c8175c87c92672666b9.tar.bz2
ayatana-indicator-datetime-e365214c51f8673feb293c8175c87c92672666b9.zip
when deciding whether to do a bubble or snap notification, see if the server supports actions.
-rw-r--r--src/snap.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/snap.cpp b/src/snap.cpp
index dcad68a..b1a2e51 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -27,6 +27,9 @@
#include <glib/gi18n.h>
#include <glib.h>
+#include <set>
+#include <string>
+
#define ALARM_SOUND_FILENAME "/usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg"
namespace unity {
@@ -177,22 +180,14 @@ void snap_data_destroy_notify(gpointer gdata)
delete static_cast<SnapData*>(gdata);
}
-bool server_is_notify_osd(void)
+std::set<std::string> get_server_caps()
{
- static bool tested = false;
- static bool is_notify_osd = false;
-
- if (G_UNLIKELY(!tested))
- {
- gchar* name=nullptr;
- notify_get_server_info(&name, nullptr, nullptr, nullptr);
- is_notify_osd = !g_strcmp0(name, "notify-osd");
- g_free(name);
-
- tested = true;
- }
-
- return is_notify_osd;
+ std::set<std::string> caps_set;
+ auto caps_gl = notify_get_server_caps();
+ for(auto l=caps_gl; l!=nullptr; l=l->next)
+ caps_set.insert((const char*)l->data);
+ g_list_free_full(caps_gl, g_free);
+ return caps_set;
}
typedef enum
@@ -207,11 +202,22 @@ NotifyMode;
NotifyMode get_notify_mode()
{
- // no real point in showing snap decisions on the desktop...
- if (server_is_notify_osd())
- return NOTIFY_MODE_BUBBLE;
+ static NotifyMode mode;
+ static bool mode_inited = false;
+
+ if (G_UNLIKELY(!mode_inited))
+ {
+ const auto caps = get_server_caps();
+
+ if (caps.count("actions"))
+ mode = NOTIFY_MODE_SNAP;
+ else
+ mode = NOTIFY_MODE_BUBBLE;
+
+ mode_inited = true;
+ }
- return NOTIFY_MODE_SNAP;
+ return mode;
}
void show_notification (SnapData* data, NotifyMode mode)