Merge lp:~larsu/unity-notifications/revert-timeout into lp:unity-notifications

Proposed by Lars Karlitski
Status: Needs review
Proposed branch: lp:~larsu/unity-notifications/revert-timeout
Merge into: lp:unity-notifications
Diff against target: 148 lines (+26/-27)
6 files modified
examples/example.py (+0/-3)
examples/sd-example-password-entry.py (+3/-4)
examples/sd-example-user-auth.py (+3/-4)
include/NotificationServer.h (+1/-1)
include/notify-backend.h.in (+0/-1)
src/NotificationServer.cpp (+19/-14)
To merge this branch: bzr merge lp:~larsu/unity-notifications/revert-timeout
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity API Team Pending
Review via email: mp+222218@code.launchpad.net

Commit message

Remove timeout hint for snap decisions in favor of the standard timeout parameter

Description of the change

Remove timeout hint for snap decisions in favor of the standard timeout parameter

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

Unmerged revisions

210. By Lars Karlitski

Honor expire timeout for snap decisions

Mostly so that providers of snap decisions can set the expire timeout to 0 if
they want the notification to stay on screen until it is interacted with.

The timeouts for other notifications are still decided by the server.

209. By Lars Karlitski

Revert r207: add timeout hint for snap decisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/example.py'
2--- examples/example.py 2014-05-07 15:32:40 +0000
3+++ examples/example.py 2014-06-05 15:41:13 +0000
4@@ -49,7 +49,6 @@
5 'x-canonical-private-icon-only': False,
6 'x-canonical-truncation': False,
7 'x-canonical-snap-decisions': False,
8- 'x-canonical-snap-decisions-timeout':False,
9 'x-canonical-switch-to-application': False,
10 'x-canonical-secondary-icon': False,
11 'x-canonical-private-button-tint': False,
12@@ -108,8 +107,6 @@
13 print "\tx-canonical-truncation"
14 if capabilities['x-canonical-snap-decisions']:
15 print "\tx-canonical-snap-decisions"
16- if capabilities['x-canonical-snap-decisions-timeout']:
17- print "\tx-canonical-snap-decisions-timeout"
18 if capabilities['x-canonical-switch-to-application']:
19 print "\tx-canonical-switch-to-application"
20 if capabilities['x-canonical-secondary-icon']:
21
22=== modified file 'examples/sd-example-password-entry.py'
23--- examples/sd-example-password-entry.py 2014-05-07 15:32:40 +0000
24+++ examples/sd-example-password-entry.py 2014-06-05 15:41:13 +0000
25@@ -118,10 +118,9 @@
26 n.set_hint ("x-canonical-private-menu-model", menu_model_paths.end ());
27
28 # indicate to the notification-daemon, that we want to use snap-decisions
29- n.set_hint ("x-canonical-snap-decisions", GLib.Variant.new_string("true"));
30- n.set_hint ("x-canonical-snap-decisions-timeout", GLib.Variant.new_int32(90000));
31- n.set_hint ("x-canonical-private-button-tint", GLib.Variant.new_string("true"));
32- n.set_hint ("x-canonical-non-shaped-icon", GLib.Variant.new_string("true"));
33+ n.set_hint_string ("x-canonical-snap-decisions", "true");
34+ n.set_hint_string ("x-canonical-private-button-tint", "true");
35+ n.set_hint_string ("x-canonical-non-shaped-icon", "true");
36
37 Gio.bus_own_name(Gio.BusType.SESSION, APPLICATION_ID, 0, bus_acquired, None, None)
38
39
40=== modified file 'examples/sd-example-user-auth.py'
41--- examples/sd-example-user-auth.py 2014-05-07 15:32:40 +0000
42+++ examples/sd-example-user-auth.py 2014-06-05 15:41:13 +0000
43@@ -132,10 +132,9 @@
44 n.set_hint ("x-canonical-private-menu-model", menu_model_paths.end ());
45
46 # indicate to the notification-daemon, that we want to use snap-decisions
47- n.set_hint ("x-canonical-snap-decisions", GLib.Variant.new_string("true"));
48- n.set_hint ("x-canonical-snap-decisions-timeout", GLib.Variant.new_int32 (90000));
49- n.set_hint ("x-canonical-private-button-tint", GLib.Variant.new_string("true"));
50- n.set_hint ("x-canonical-non-shaped-icon", GLib.Variant.new_string("true"));
51+ n.set_hint_string ("x-canonical-snap-decisions", "true");
52+ n.set_hint_string ("x-canonical-private-button-tint", "true");
53+ n.set_hint_string ("x-canonical-non-shaped-icon", "true");
54
55 Gio.bus_own_name(Gio.BusType.SESSION, APPLICATION_ID, 0, bus_acquired, None, None)
56
57
58=== modified file 'include/NotificationServer.h'
59--- include/NotificationServer.h 2013-10-18 08:19:39 +0000
60+++ include/NotificationServer.h 2014-06-05 15:41:13 +0000
61@@ -73,7 +73,7 @@
62 void dataChanged(unsigned int id);
63
64 private:
65- Notification* buildNotification(NotificationID id, const Hints &hints);
66+ Notification* buildNotification(NotificationID id, int expireTimeout, const Hints &hints);
67 NotificationModel &model;
68 unsigned int idCounter;
69
70
71=== modified file 'include/notify-backend.h.in'
72--- include/notify-backend.h.in 2014-05-07 15:32:40 +0000
73+++ include/notify-backend.h.in 2014-06-05 15:41:13 +0000
74@@ -66,6 +66,5 @@
75 #define BUTTON_TINT_HINT "x-canonical-private-button-tint"
76 #define TRUNCATION_HINT "x-canonical-truncation"
77 #define APPEND_HINT "x-canonical-append"
78-#define TIMEOUT_HINT "x-canonical-snap-decisions-timeout"
79
80 #endif
81
82=== modified file 'src/NotificationServer.cpp'
83--- src/NotificationServer.cpp 2014-06-02 10:58:21 +0000
84+++ src/NotificationServer.cpp 2014-06-05 15:41:13 +0000
85@@ -57,13 +57,11 @@
86 capabilities.push_back(NON_SHAPED_ICON_HINT);
87 capabilities.push_back(MENU_MODEL_HINT);
88 capabilities.push_back(INTERACTIVE_HINT);
89- capabilities.push_back(TIMEOUT_HINT);
90
91 return capabilities;
92 }
93
94-Notification* NotificationServer::buildNotification(NotificationID id, const Hints &hints) {
95- int expireTimeout = 0;
96+Notification* NotificationServer::buildNotification(NotificationID id, int expireTimeout, const Hints &hints) {
97 Notification::Urgency urg = Notification::Urgency::Low;
98 if(hints.find(URGENCY_HINT) != hints.end()) {
99 QVariant u = hints[URGENCY_HINT].variant();
100@@ -74,22 +72,29 @@
101 }
102 }
103 Notification::Type ntype = Notification::Type::Ephemeral;
104- expireTimeout = 5000;
105 if(hints.find(SYNCH_HINT) != hints.end()) {
106- expireTimeout = 3000;
107 ntype = Notification::Type::Confirmation;
108 } else if (hints.find(SNAP_HINT) != hints.end()) {
109- QVariant u = hints[TIMEOUT_HINT].variant();
110- if(!u.canConvert(QVariant::Int)) {
111- expireTimeout = 60000;
112- } else {
113- expireTimeout = u.toInt();
114- }
115-
116 ntype = Notification::Type::SnapDecision;
117 } else if(hints.find(INTERACTIVE_HINT) != hints.end()) {
118 ntype = Notification::Type::Interactive;
119- expireTimeout = 5000;
120+ }
121+
122+ switch (ntype) {
123+ case Notification::Type::Confirmation:
124+ expireTimeout = 3000;
125+ break;
126+
127+ // only snap decisions are allowed to override the timeout
128+ case Notification::Type::SnapDecision:
129+ if (expireTimeout == -1) {
130+ expireTimeout = 60000;
131+ }
132+ break;
133+
134+ default:
135+ expireTimeout = 5000;
136+ break;
137 }
138
139 Notification* n = new Notification(id, expireTimeout, urg, ntype, this);
140@@ -142,7 +147,7 @@
141 }
142 }
143
144- Notification *n = buildNotification(currentId, hints);
145+ Notification *n = buildNotification(currentId, expire_timeout, hints);
146 if(!n) {
147 fprintf(stderr, "Could not build notification object.\n");
148 return FAILURE;

Subscribers

People subscribed via source and target branches

to all changes: