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
=== modified file 'examples/example.py'
--- examples/example.py 2014-05-07 15:32:40 +0000
+++ examples/example.py 2014-06-05 15:41:13 +0000
@@ -49,7 +49,6 @@
49 'x-canonical-private-icon-only': False,49 'x-canonical-private-icon-only': False,
50 'x-canonical-truncation': False,50 'x-canonical-truncation': False,
51 'x-canonical-snap-decisions': False,51 'x-canonical-snap-decisions': False,
52 'x-canonical-snap-decisions-timeout':False,
53 'x-canonical-switch-to-application': False,52 'x-canonical-switch-to-application': False,
54 'x-canonical-secondary-icon': False,53 'x-canonical-secondary-icon': False,
55 'x-canonical-private-button-tint': False,54 'x-canonical-private-button-tint': False,
@@ -108,8 +107,6 @@
108 print "\tx-canonical-truncation"107 print "\tx-canonical-truncation"
109 if capabilities['x-canonical-snap-decisions']:108 if capabilities['x-canonical-snap-decisions']:
110 print "\tx-canonical-snap-decisions"109 print "\tx-canonical-snap-decisions"
111 if capabilities['x-canonical-snap-decisions-timeout']:
112 print "\tx-canonical-snap-decisions-timeout"
113 if capabilities['x-canonical-switch-to-application']:110 if capabilities['x-canonical-switch-to-application']:
114 print "\tx-canonical-switch-to-application"111 print "\tx-canonical-switch-to-application"
115 if capabilities['x-canonical-secondary-icon']:112 if capabilities['x-canonical-secondary-icon']:
116113
=== modified file 'examples/sd-example-password-entry.py'
--- examples/sd-example-password-entry.py 2014-05-07 15:32:40 +0000
+++ examples/sd-example-password-entry.py 2014-06-05 15:41:13 +0000
@@ -118,10 +118,9 @@
118 n.set_hint ("x-canonical-private-menu-model", menu_model_paths.end ());118 n.set_hint ("x-canonical-private-menu-model", menu_model_paths.end ());
119119
120 # indicate to the notification-daemon, that we want to use snap-decisions120 # indicate to the notification-daemon, that we want to use snap-decisions
121 n.set_hint ("x-canonical-snap-decisions", GLib.Variant.new_string("true"));121 n.set_hint_string ("x-canonical-snap-decisions", "true");
122 n.set_hint ("x-canonical-snap-decisions-timeout", GLib.Variant.new_int32(90000));122 n.set_hint_string ("x-canonical-private-button-tint", "true");
123 n.set_hint ("x-canonical-private-button-tint", GLib.Variant.new_string("true"));123 n.set_hint_string ("x-canonical-non-shaped-icon", "true");
124 n.set_hint ("x-canonical-non-shaped-icon", GLib.Variant.new_string("true"));
125124
126 Gio.bus_own_name(Gio.BusType.SESSION, APPLICATION_ID, 0, bus_acquired, None, None)125 Gio.bus_own_name(Gio.BusType.SESSION, APPLICATION_ID, 0, bus_acquired, None, None)
127126
128127
=== modified file 'examples/sd-example-user-auth.py'
--- examples/sd-example-user-auth.py 2014-05-07 15:32:40 +0000
+++ examples/sd-example-user-auth.py 2014-06-05 15:41:13 +0000
@@ -132,10 +132,9 @@
132 n.set_hint ("x-canonical-private-menu-model", menu_model_paths.end ());132 n.set_hint ("x-canonical-private-menu-model", menu_model_paths.end ());
133133
134 # indicate to the notification-daemon, that we want to use snap-decisions134 # indicate to the notification-daemon, that we want to use snap-decisions
135 n.set_hint ("x-canonical-snap-decisions", GLib.Variant.new_string("true"));135 n.set_hint_string ("x-canonical-snap-decisions", "true");
136 n.set_hint ("x-canonical-snap-decisions-timeout", GLib.Variant.new_int32 (90000));136 n.set_hint_string ("x-canonical-private-button-tint", "true");
137 n.set_hint ("x-canonical-private-button-tint", GLib.Variant.new_string("true"));137 n.set_hint_string ("x-canonical-non-shaped-icon", "true");
138 n.set_hint ("x-canonical-non-shaped-icon", GLib.Variant.new_string("true"));
139138
140 Gio.bus_own_name(Gio.BusType.SESSION, APPLICATION_ID, 0, bus_acquired, None, None)139 Gio.bus_own_name(Gio.BusType.SESSION, APPLICATION_ID, 0, bus_acquired, None, None)
141140
142141
=== modified file 'include/NotificationServer.h'
--- include/NotificationServer.h 2013-10-18 08:19:39 +0000
+++ include/NotificationServer.h 2014-06-05 15:41:13 +0000
@@ -73,7 +73,7 @@
73 void dataChanged(unsigned int id);73 void dataChanged(unsigned int id);
7474
75private:75private:
76 Notification* buildNotification(NotificationID id, const Hints &hints);76 Notification* buildNotification(NotificationID id, int expireTimeout, const Hints &hints);
77 NotificationModel &model;77 NotificationModel &model;
78 unsigned int idCounter;78 unsigned int idCounter;
7979
8080
=== modified file 'include/notify-backend.h.in'
--- include/notify-backend.h.in 2014-05-07 15:32:40 +0000
+++ include/notify-backend.h.in 2014-06-05 15:41:13 +0000
@@ -66,6 +66,5 @@
66#define BUTTON_TINT_HINT "x-canonical-private-button-tint"66#define BUTTON_TINT_HINT "x-canonical-private-button-tint"
67#define TRUNCATION_HINT "x-canonical-truncation"67#define TRUNCATION_HINT "x-canonical-truncation"
68#define APPEND_HINT "x-canonical-append"68#define APPEND_HINT "x-canonical-append"
69#define TIMEOUT_HINT "x-canonical-snap-decisions-timeout"
7069
71#endif70#endif
7271
=== modified file 'src/NotificationServer.cpp'
--- src/NotificationServer.cpp 2014-06-02 10:58:21 +0000
+++ src/NotificationServer.cpp 2014-06-05 15:41:13 +0000
@@ -57,13 +57,11 @@
57 capabilities.push_back(NON_SHAPED_ICON_HINT);57 capabilities.push_back(NON_SHAPED_ICON_HINT);
58 capabilities.push_back(MENU_MODEL_HINT);58 capabilities.push_back(MENU_MODEL_HINT);
59 capabilities.push_back(INTERACTIVE_HINT);59 capabilities.push_back(INTERACTIVE_HINT);
60 capabilities.push_back(TIMEOUT_HINT);
6160
62 return capabilities;61 return capabilities;
63}62}
6463
65Notification* NotificationServer::buildNotification(NotificationID id, const Hints &hints) {64Notification* NotificationServer::buildNotification(NotificationID id, int expireTimeout, const Hints &hints) {
66 int expireTimeout = 0;
67 Notification::Urgency urg = Notification::Urgency::Low;65 Notification::Urgency urg = Notification::Urgency::Low;
68 if(hints.find(URGENCY_HINT) != hints.end()) {66 if(hints.find(URGENCY_HINT) != hints.end()) {
69 QVariant u = hints[URGENCY_HINT].variant();67 QVariant u = hints[URGENCY_HINT].variant();
@@ -74,22 +72,29 @@
74 }72 }
75 }73 }
76 Notification::Type ntype = Notification::Type::Ephemeral;74 Notification::Type ntype = Notification::Type::Ephemeral;
77 expireTimeout = 5000;
78 if(hints.find(SYNCH_HINT) != hints.end()) {75 if(hints.find(SYNCH_HINT) != hints.end()) {
79 expireTimeout = 3000;
80 ntype = Notification::Type::Confirmation;76 ntype = Notification::Type::Confirmation;
81 } else if (hints.find(SNAP_HINT) != hints.end()) {77 } else if (hints.find(SNAP_HINT) != hints.end()) {
82 QVariant u = hints[TIMEOUT_HINT].variant();
83 if(!u.canConvert(QVariant::Int)) {
84 expireTimeout = 60000;
85 } else {
86 expireTimeout = u.toInt();
87 }
88
89 ntype = Notification::Type::SnapDecision;78 ntype = Notification::Type::SnapDecision;
90 } else if(hints.find(INTERACTIVE_HINT) != hints.end()) {79 } else if(hints.find(INTERACTIVE_HINT) != hints.end()) {
91 ntype = Notification::Type::Interactive;80 ntype = Notification::Type::Interactive;
92 expireTimeout = 5000;81 }
82
83 switch (ntype) {
84 case Notification::Type::Confirmation:
85 expireTimeout = 3000;
86 break;
87
88 // only snap decisions are allowed to override the timeout
89 case Notification::Type::SnapDecision:
90 if (expireTimeout == -1) {
91 expireTimeout = 60000;
92 }
93 break;
94
95 default:
96 expireTimeout = 5000;
97 break;
93 }98 }
9499
95 Notification* n = new Notification(id, expireTimeout, urg, ntype, this);100 Notification* n = new Notification(id, expireTimeout, urg, ntype, this);
@@ -142,7 +147,7 @@
142 }147 }
143 }148 }
144149
145 Notification *n = buildNotification(currentId, hints);150 Notification *n = buildNotification(currentId, expire_timeout, hints);
146 if(!n) {151 if(!n) {
147 fprintf(stderr, "Could not build notification object.\n");152 fprintf(stderr, "Could not build notification object.\n");
148 return FAILURE;153 return FAILURE;

Subscribers

People subscribed via source and target branches

to all changes: