diff -Nru indicator-datetime-13.10.0+14.04.20140227/debian/changelog indicator-datetime-13.10.0+14.04.20140227.1/debian/changelog --- indicator-datetime-13.10.0+14.04.20140227/debian/changelog 2014-02-27 20:35:12.000000000 +0000 +++ indicator-datetime-13.10.0+14.04.20140227.1/debian/changelog 2014-02-27 20:35:12.000000000 +0000 @@ -1,3 +1,11 @@ +indicator-datetime (13.10.0+14.04.20140227.1-0ubuntu1) trusty; urgency=low + + [ Charles Kerr ] + * When the notification engine is notify-osd, use bubble notifications + instead of the phone's snap decisions. (LP: #1283142) + + -- Ubuntu daily release Thu, 27 Feb 2014 18:44:10 +0000 + indicator-datetime (13.10.0+14.04.20140227-0ubuntu1) trusty; urgency=low [ Charles Kerr ] diff -Nru indicator-datetime-13.10.0+14.04.20140227/src/snap.cpp indicator-datetime-13.10.0+14.04.20140227.1/src/snap.cpp --- indicator-datetime-13.10.0+14.04.20140227/src/snap.cpp 2014-02-27 10:58:48.000000000 +0000 +++ indicator-datetime-13.10.0+14.04.20140227.1/src/snap.cpp 2014-02-27 18:44:03.000000000 +0000 @@ -27,6 +27,9 @@ #include #include +#include +#include + #define ALARM_SOUND_FILENAME "/usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg" namespace unity { @@ -169,12 +172,57 @@ data->dismiss(data->appointment); } +void on_snap_closed(NotifyNotification*, gpointer) +{ + stop_alarm_sound(); +} + void snap_data_destroy_notify(gpointer gdata) { delete static_cast(gdata); } -void show_snap_decision(SnapData* data) +std::set get_server_caps() +{ + std::set 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 +{ + // just a bubble... no actions, no audio + NOTIFY_MODE_BUBBLE, + + // a snap decision popup dialog + audio + NOTIFY_MODE_SNAP +} +NotifyMode; + +NotifyMode get_notify_mode() +{ + 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 mode; +} + +void show_notification (SnapData* data, NotifyMode mode) { const Appointment& appointment = data->appointment; @@ -184,10 +232,14 @@ const gchar* icon_name = "alarm-clock"; auto nn = notify_notification_new(title, body.c_str(), icon_name); - notify_notification_set_hint_string(nn, "x-canonical-snap-decisions", "true"); - notify_notification_set_hint_string(nn, "x-canonical-private-button-tint", "true"); - notify_notification_add_action(nn, "show", _("Show"), on_snap_show, data, nullptr); - notify_notification_add_action(nn, "dismiss", _("Dismiss"), on_snap_dismiss, data, nullptr); + if (mode == NOTIFY_MODE_SNAP) + { + notify_notification_set_hint_string(nn, "x-canonical-snap-decisions", "true"); + notify_notification_set_hint_string(nn, "x-canonical-private-button-tint", "true"); + notify_notification_add_action(nn, "show", _("Show"), on_snap_show, data, nullptr); + notify_notification_add_action(nn, "dismiss", _("Dismiss"), on_snap_dismiss, data, nullptr); + g_signal_connect(G_OBJECT(nn), "closed", G_CALLBACK(on_snap_closed), data); + } g_object_set_data_full(G_OBJECT(nn), "snap-data", data, snap_data_destroy_notify); GError * error = nullptr; @@ -215,8 +267,17 @@ data->show = show; data->dismiss = dismiss; - play_alarm_sound(); - show_snap_decision(data); + switch (get_notify_mode()) + { + case NOTIFY_MODE_BUBBLE: + show_notification(data, NOTIFY_MODE_BUBBLE); + break; + + default: + show_notification(data, NOTIFY_MODE_SNAP); + play_alarm_sound(); + break; + } } } // unnamed namespace