Merge lp:~dbarth/indicator-datetime/mute-notifications-15.04 into lp:indicator-datetime/15.04

Proposed by David Barth
Status: Needs review
Proposed branch: lp:~dbarth/indicator-datetime/mute-notifications-15.04
Merge into: lp:indicator-datetime/15.04
Diff against target: 104 lines (+53/-2)
2 files modified
debian/control (+2/-0)
src/snap.cpp (+51/-2)
To merge this branch: bzr merge lp:~dbarth/indicator-datetime/mute-notifications-15.04
Reviewer Review Type Date Requested Status
Sebastien Bacher Needs Fixing
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+282992@code.launchpad.net

Commit message

don't show snap/appointments if the calendar app is blacklisted in system notifications settings
(backported from trunk mp)

Description of the change

don't show snap/appointments if the calendar app is blacklisted in system notifications settings
(backported from trunk mp)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
425. By David Barth

make ^Cde a bit more robust, and add some debug statements

426. By David Barth

fix

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
427. By David Barth

adjust title and notification icon according to the event type

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks for the work, the "adjust title and notification icon according to the event type" seems a different issue, could you use a different merge request/branch for it?
the commit message states "don't show snap/appointments", could you give some more details? does it concern the indicator menu or the reminders?

review: Needs Fixing

Unmerged revisions

427. By David Barth

adjust title and notification icon according to the event type

426. By David Barth

fix

425. By David Barth

make ^Cde a bit more robust, and add some debug statements

424. By David Barth

don't show snap/appointments if the calendar app is blacklisted in system notifications settings

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-10-14 02:13:21 +0000
3+++ debian/control 2016-01-22 13:17:56 +0000
4@@ -20,6 +20,7 @@
5 libgtest-dev,
6 libdbustest1-dev,
7 dbus-test-runner,
8+ gsettings-ubuntu-schemas,
9 python3-dbusmock,
10 # for 12h/24h locale unit tests:
11 locales,
12@@ -41,6 +42,7 @@
13 Architecture: any
14 Depends: ${shlibs:Depends},
15 ${misc:Depends},
16+ gsettings-ubuntu-schemas,
17 systemd-services,
18 systemd-shim,
19 Recommends: indicator-applet | indicator-renderer,
20
21=== modified file 'src/snap.cpp'
22--- src/snap.cpp 2015-10-13 23:28:51 +0000
23+++ src/snap.cpp 2016-01-22 13:17:56 +0000
24@@ -94,6 +94,12 @@
25 // force the system to stay awake
26 auto awake = std::make_shared<uin::Awake>(m_engine->app_name());
27
28+ // mute notifications of appointments according to system settings
29+ // Note: alarms will still fire up normally below
30+ if (! appointment.is_ubuntu_alarm() &&
31+ notifications_disabled())
32+ return;
33+
34 // calendar events are muted in silent mode; alarm clocks never are
35 std::shared_ptr<uin::Sound> sound;
36 if (appointment.is_ubuntu_alarm() || !silent_mode()) {
37@@ -117,7 +123,7 @@
38 const auto minutes = std::chrono::minutes(m_settings->alarm_duration.get());
39 uin::Builder b;
40 b.set_body (appointment.summary);
41- b.set_icon_name ("alarm-clock");
42+ b.set_icon_name (appointment.is_ubuntu_alarm() ? "alarm-clock" : "reminder");
43 b.add_hint (uin::Builder::HINT_NONSHAPED_ICON);
44
45 const char * timefmt;
46@@ -131,7 +137,14 @@
47 timefmt = _("%a, %H:%M");
48 }
49 const auto timestr = appointment.begin.format(timefmt);
50- auto title = g_strdup_printf(_("Alarm %s"), timestr.c_str());
51+
52+ const char * titlefmt;
53+ if (appointment.is_ubuntu_alarm()) {
54+ titlefmt = _("Alarm %s");
55+ } else {
56+ titlefmt = _("Event %s");
57+ }
58+ auto title = g_strdup_printf(titlefmt, timestr.c_str());
59 b.set_title (title);
60 g_free (title);
61 b.set_timeout (std::chrono::duration_cast<std::chrono::seconds>(minutes));
62@@ -160,6 +173,42 @@
63
64 private:
65
66+ bool notifications_disabled() const
67+ {
68+ // check if calendar events are disabled in system notification settings
69+ GSettings *cunh = g_settings_new("com.ubuntu.notifications.hub");
70+ GVariant *blacklist = g_settings_get_value(cunh, "blacklist");
71+
72+ if (blacklist == NULL) {
73+ g_warning("%s Couldn't find notifications blacklist", G_STRLOC);
74+ return false;
75+ }
76+
77+ GVariantIter *iter;
78+ g_variant_get(blacklist, "a(ss)", &iter);
79+
80+ gchar *pkg;
81+ gchar *app;
82+ bool result = false;
83+
84+ while(g_variant_iter_loop(iter, "(ss)", &pkg, &app)) {
85+ if (g_strcmp0(pkg, "com.ubuntu.calendar") == 0) {
86+ result = true; // ie, don't show the appointments
87+ g_info("%s calendar notifications blacklisted", G_STRLOC);
88+ g_free(pkg);
89+ g_free(app);
90+ break;
91+ }
92+ }
93+
94+ g_object_unref(cunh);
95+ g_variant_unref(blacklist);
96+ g_variant_iter_free(iter);
97+
98+ return result;
99+ }
100+
101+
102 static void on_sound_proxy_ready(GObject* /*source_object*/, GAsyncResult* res, gpointer gself)
103 {
104 GError * error;

Subscribers

People subscribed via source and target branches