Merge lp:~xavi-garcia-mena/indicator-sound/bluetooth-icons-bug-1415480 into lp:indicator-sound/15.10
- bluetooth-icons-bug-1415480
- Merge into trunk.15.10
Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Charles Kerr | ||||||||||||||||
Approved revision: | 510 | ||||||||||||||||
Merged at revision: | 508 | ||||||||||||||||
Proposed branch: | lp:~xavi-garcia-mena/indicator-sound/bluetooth-icons-bug-1415480 | ||||||||||||||||
Merge into: | lp:indicator-sound/15.10 | ||||||||||||||||
Diff against target: |
614 lines (+437/-40) 6 files modified
src/CMakeLists.txt (+1/-0) src/service.vala (+329/-27) src/sound-menu.vala (+23/-0) src/volume-control-pulse.vala (+69/-12) src/volume-control.vala (+14/-0) tests/notifications-test.cc (+1/-1) |
||||||||||||||||
To merge this branch: | bzr merge lp:~xavi-garcia-mena/indicator-sound/bluetooth-icons-bug-1415480 | ||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+272735@code.launchpad.net |
Commit message
Added the code to change the icons and label when a bluetooth headset is connected
Description of the change
Added the code to change the icons and label when a bluetooth headset is connected
PS Jenkins bot (ps-jenkins) wrote : | # |
Charles Kerr (charlesk) wrote : | # |
So many possible states!
Writing coverage test for this will be fun... :-)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:507
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 508. By Xavi Garcia
-
Updated to show a label stating the active output
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:508
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 509. By Xavi Garcia
-
Added USB and HDMI active outputs
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:509
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 510. By Xavi Garcia
-
fixed panel root panel icons
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:510
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Charles Kerr (charlesk) : | # |
Sebastien Bacher (seb128) wrote : | # |
that seems to have broken unity7 notifications (when scrolling over the indicator)
Xavi Garcia (xavi-garcia-mena) wrote : | # |
As discussed with Lars Uebernickel, a fix for unity7 is ready to go.
This branch adds a new string to the notification.
Preview Diff
1 | === modified file 'src/CMakeLists.txt' | |||
2 | --- src/CMakeLists.txt 2015-02-19 16:23:01 +0000 | |||
3 | +++ src/CMakeLists.txt 2015-10-05 12:20:39 +0000 | |||
4 | @@ -103,6 +103,7 @@ | |||
5 | 103 | sound-menu.vala | 103 | sound-menu.vala |
6 | 104 | DEPENDS | 104 | DEPENDS |
7 | 105 | media-player | 105 | media-player |
8 | 106 | volume-control | ||
9 | 106 | ) | 107 | ) |
10 | 107 | vala_add(indicator-sound-service | 108 | vala_add(indicator-sound-service |
11 | 108 | accounts-service-user.vala | 109 | accounts-service-user.vala |
12 | 109 | 110 | ||
13 | === modified file 'src/service.vala' | |||
14 | --- src/service.vala 2015-08-27 11:42:21 +0000 | |||
15 | +++ src/service.vala 2015-10-05 12:20:39 +0000 | |||
16 | @@ -52,6 +52,8 @@ | |||
17 | 52 | this.notify["visible"].connect ( () => this.update_root_icon () ); | 52 | this.notify["visible"].connect ( () => this.update_root_icon () ); |
18 | 53 | 53 | ||
19 | 54 | this.volume_control = volume; | 54 | this.volume_control = volume; |
20 | 55 | this.volume_control.active_output_changed.connect (this.update_root_icon); | ||
21 | 56 | this.volume_control.active_output_changed.connect (this.update_notification); | ||
22 | 55 | 57 | ||
23 | 56 | this.accounts_service = accounts; | 58 | this.accounts_service = accounts; |
24 | 57 | /* If we're on the greeter, don't export */ | 59 | /* If we're on the greeter, don't export */ |
25 | @@ -90,6 +92,10 @@ | |||
26 | 90 | this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE); | 92 | this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE); |
27 | 91 | }); | 93 | }); |
28 | 92 | 94 | ||
29 | 95 | this.menus.@foreach ( (profile, menu) => { | ||
30 | 96 | this.volume_control.active_output_changed.connect (menu.update_volume_slider); | ||
31 | 97 | }); | ||
32 | 98 | |||
33 | 93 | this.sync_preferred_players (); | 99 | this.sync_preferred_players (); |
34 | 94 | this.settings.changed["interested-media-players"].connect ( () => { | 100 | this.settings.changed["interested-media-players"].connect ( () => { |
35 | 95 | this.sync_preferred_players (); | 101 | this.sync_preferred_players (); |
36 | @@ -245,17 +251,7 @@ | |||
37 | 245 | 251 | ||
38 | 246 | void update_root_icon () { | 252 | void update_root_icon () { |
39 | 247 | double volume = this.volume_control.volume.volume; | 253 | double volume = this.volume_control.volume.volume; |
51 | 248 | string icon; | 254 | string icon = get_volume_root_icon (volume, this.volume_control.mute, volume_control.active_output); |
41 | 249 | if (this.volume_control.mute || volume <= 0.0) | ||
42 | 250 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
43 | 251 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
44 | 252 | icon = "audio-volume-muted-panel"; | ||
45 | 253 | else if (volume <= 0.3) | ||
46 | 254 | icon = "audio-volume-low-panel"; | ||
47 | 255 | else if (volume <= 0.7) | ||
48 | 256 | icon = "audio-volume-medium-panel"; | ||
49 | 257 | else | ||
50 | 258 | icon = "audio-volume-high-panel"; | ||
52 | 259 | 255 | ||
53 | 260 | string accessible_name; | 256 | string accessible_name; |
54 | 261 | if (this.volume_control.mute) { | 257 | if (this.volume_control.mute) { |
55 | @@ -282,6 +278,292 @@ | |||
56 | 282 | private bool notify_server_supports_sync = false; | 278 | private bool notify_server_supports_sync = false; |
57 | 283 | private bool block_info_notifications = false; | 279 | private bool block_info_notifications = false; |
58 | 284 | 280 | ||
59 | 281 | private string get_volume_icon (double volume, VolumeControl.ActiveOutput active_output) | ||
60 | 282 | { | ||
61 | 283 | string icon = ""; | ||
62 | 284 | switch (active_output) | ||
63 | 285 | { | ||
64 | 286 | case VolumeControl.ActiveOutput.SPEAKERS: | ||
65 | 287 | if (volume <= 0.0) | ||
66 | 288 | icon = "audio-volume-muted"; | ||
67 | 289 | else if (volume <= 0.3) | ||
68 | 290 | icon = "audio-volume-low"; | ||
69 | 291 | else if (volume <= 0.7) | ||
70 | 292 | icon = "audio-volume-medium"; | ||
71 | 293 | else | ||
72 | 294 | icon = "audio-volume-high"; | ||
73 | 295 | break; | ||
74 | 296 | case VolumeControl.ActiveOutput.HEADPHONES: | ||
75 | 297 | if (volume <= 0.0) | ||
76 | 298 | icon = "audio-volume-muted"; | ||
77 | 299 | else if (volume <= 0.3) | ||
78 | 300 | icon = "audio-volume-low"; | ||
79 | 301 | else if (volume <= 0.7) | ||
80 | 302 | icon = "audio-volume-medium"; | ||
81 | 303 | else | ||
82 | 304 | icon = "audio-volume-high"; | ||
83 | 305 | break; | ||
84 | 306 | case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: | ||
85 | 307 | if (volume <= 0.0) | ||
86 | 308 | icon = "audio-volume-muted"; | ||
87 | 309 | else if (volume <= 0.3) | ||
88 | 310 | icon = "audio-volume-low"; | ||
89 | 311 | else if (volume <= 0.7) | ||
90 | 312 | icon = "audio-volume-medium"; | ||
91 | 313 | else | ||
92 | 314 | icon = "audio-volume-high"; | ||
93 | 315 | break; | ||
94 | 316 | case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: | ||
95 | 317 | if (volume <= 0.0) | ||
96 | 318 | icon = "audio-volume-muted"; | ||
97 | 319 | else if (volume <= 0.3) | ||
98 | 320 | icon = "audio-volume-low"; | ||
99 | 321 | else if (volume <= 0.7) | ||
100 | 322 | icon = "audio-volume-medium"; | ||
101 | 323 | else | ||
102 | 324 | icon = "audio-volume-high"; | ||
103 | 325 | break; | ||
104 | 326 | case VolumeControl.ActiveOutput.USB_SPEAKER: | ||
105 | 327 | if (volume <= 0.0) | ||
106 | 328 | icon = "audio-volume-muted"; | ||
107 | 329 | else if (volume <= 0.3) | ||
108 | 330 | icon = "audio-volume-low"; | ||
109 | 331 | else if (volume <= 0.7) | ||
110 | 332 | icon = "audio-volume-medium"; | ||
111 | 333 | else | ||
112 | 334 | icon = "audio-volume-high"; | ||
113 | 335 | break; | ||
114 | 336 | case VolumeControl.ActiveOutput.USB_HEADPHONES: | ||
115 | 337 | if (volume <= 0.0) | ||
116 | 338 | icon = "audio-volume-muted"; | ||
117 | 339 | else if (volume <= 0.3) | ||
118 | 340 | icon = "audio-volume-low"; | ||
119 | 341 | else if (volume <= 0.7) | ||
120 | 342 | icon = "audio-volume-medium"; | ||
121 | 343 | else | ||
122 | 344 | icon = "audio-volume-high"; | ||
123 | 345 | break; | ||
124 | 346 | case VolumeControl.ActiveOutput.HDMI_SPEAKER: | ||
125 | 347 | if (volume <= 0.0) | ||
126 | 348 | icon = "audio-volume-muted"; | ||
127 | 349 | else if (volume <= 0.3) | ||
128 | 350 | icon = "audio-volume-low"; | ||
129 | 351 | else if (volume <= 0.7) | ||
130 | 352 | icon = "audio-volume-medium"; | ||
131 | 353 | else | ||
132 | 354 | icon = "audio-volume-high"; | ||
133 | 355 | break; | ||
134 | 356 | case VolumeControl.ActiveOutput.HDMI_HEADPHONES: | ||
135 | 357 | if (volume <= 0.0) | ||
136 | 358 | icon = "audio-volume-muted"; | ||
137 | 359 | else if (volume <= 0.3) | ||
138 | 360 | icon = "audio-volume-low"; | ||
139 | 361 | else if (volume <= 0.7) | ||
140 | 362 | icon = "audio-volume-medium"; | ||
141 | 363 | else | ||
142 | 364 | icon = "audio-volume-high"; | ||
143 | 365 | break; | ||
144 | 366 | } | ||
145 | 367 | return icon; | ||
146 | 368 | } | ||
147 | 369 | |||
148 | 370 | private string get_volume_root_icon_by_volume (double volume, VolumeControl.ActiveOutput active_output) | ||
149 | 371 | { | ||
150 | 372 | string icon = ""; | ||
151 | 373 | switch (active_output) | ||
152 | 374 | { | ||
153 | 375 | case VolumeControl.ActiveOutput.SPEAKERS: | ||
154 | 376 | if (volume <= 0.0) | ||
155 | 377 | icon = "audio-volume-muted-panel"; | ||
156 | 378 | else if (volume <= 0.3) | ||
157 | 379 | icon = "audio-volume-low-panel"; | ||
158 | 380 | else if (volume <= 0.7) | ||
159 | 381 | icon = "audio-volume-medium-panel"; | ||
160 | 382 | else | ||
161 | 383 | icon = "audio-volume-high-panel"; | ||
162 | 384 | break; | ||
163 | 385 | case VolumeControl.ActiveOutput.HEADPHONES: | ||
164 | 386 | if (volume <= 0.0) | ||
165 | 387 | icon = "audio-volume-muted-panel"; | ||
166 | 388 | else if (volume <= 0.3) | ||
167 | 389 | icon = "audio-volume-low-panel"; | ||
168 | 390 | else if (volume <= 0.7) | ||
169 | 391 | icon = "audio-volume-medium-panel"; | ||
170 | 392 | else | ||
171 | 393 | icon = "audio-volume-high-panel"; | ||
172 | 394 | break; | ||
173 | 395 | case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: | ||
174 | 396 | if (volume <= 0.0) | ||
175 | 397 | icon = "audio-volume-muted-panel"; | ||
176 | 398 | else if (volume <= 0.3) | ||
177 | 399 | icon = "audio-volume-low-panel"; | ||
178 | 400 | else if (volume <= 0.7) | ||
179 | 401 | icon = "audio-volume-medium-panel"; | ||
180 | 402 | else | ||
181 | 403 | icon = "audio-volume-high-panel"; | ||
182 | 404 | break; | ||
183 | 405 | case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: | ||
184 | 406 | if (volume <= 0.0) | ||
185 | 407 | icon = "audio-volume-muted-panel"; | ||
186 | 408 | else if (volume <= 0.3) | ||
187 | 409 | icon = "audio-volume-low-panel"; | ||
188 | 410 | else if (volume <= 0.7) | ||
189 | 411 | icon = "audio-volume-medium-panel"; | ||
190 | 412 | else | ||
191 | 413 | icon = "audio-volume-high-panel"; | ||
192 | 414 | break; | ||
193 | 415 | case VolumeControl.ActiveOutput.USB_SPEAKER: | ||
194 | 416 | if (volume <= 0.0) | ||
195 | 417 | icon = "audio-volume-muted-panel"; | ||
196 | 418 | else if (volume <= 0.3) | ||
197 | 419 | icon = "audio-volume-low-panel"; | ||
198 | 420 | else if (volume <= 0.7) | ||
199 | 421 | icon = "audio-volume-medium-panel"; | ||
200 | 422 | else | ||
201 | 423 | icon = "audio-volume-high-panel"; | ||
202 | 424 | break; | ||
203 | 425 | case VolumeControl.ActiveOutput.USB_HEADPHONES: | ||
204 | 426 | if (volume <= 0.0) | ||
205 | 427 | icon = "audio-volume-muted-panel"; | ||
206 | 428 | else if (volume <= 0.3) | ||
207 | 429 | icon = "audio-volume-low-panel"; | ||
208 | 430 | else if (volume <= 0.7) | ||
209 | 431 | icon = "audio-volume-medium-panel"; | ||
210 | 432 | else | ||
211 | 433 | icon = "audio-volume-high-panel"; | ||
212 | 434 | break; | ||
213 | 435 | case VolumeControl.ActiveOutput.HDMI_SPEAKER: | ||
214 | 436 | if (volume <= 0.0) | ||
215 | 437 | icon = "audio-volume-muted-panel"; | ||
216 | 438 | else if (volume <= 0.3) | ||
217 | 439 | icon = "audio-volume-low-panel"; | ||
218 | 440 | else if (volume <= 0.7) | ||
219 | 441 | icon = "audio-volume-medium-panel"; | ||
220 | 442 | else | ||
221 | 443 | icon = "audio-volume-high-panel"; | ||
222 | 444 | break; | ||
223 | 445 | case VolumeControl.ActiveOutput.HDMI_HEADPHONES: | ||
224 | 446 | if (volume <= 0.0) | ||
225 | 447 | icon = "audio-volume-muted-panel"; | ||
226 | 448 | else if (volume <= 0.3) | ||
227 | 449 | icon = "audio-volume-low-panel"; | ||
228 | 450 | else if (volume <= 0.7) | ||
229 | 451 | icon = "audio-volume-medium-panel"; | ||
230 | 452 | else | ||
231 | 453 | icon = "audio-volume-high-panel"; | ||
232 | 454 | break; | ||
233 | 455 | } | ||
234 | 456 | return icon; | ||
235 | 457 | } | ||
236 | 458 | |||
237 | 459 | private string get_volume_notification_icon (double volume, bool loud, VolumeControl.ActiveOutput active_output) { | ||
238 | 460 | string icon = ""; | ||
239 | 461 | if (loud) { | ||
240 | 462 | switch (active_output) | ||
241 | 463 | { | ||
242 | 464 | case VolumeControl.ActiveOutput.SPEAKERS: | ||
243 | 465 | icon = "audio-volume-high"; | ||
244 | 466 | break; | ||
245 | 467 | case VolumeControl.ActiveOutput.HEADPHONES: | ||
246 | 468 | icon = "audio-volume-high"; | ||
247 | 469 | break; | ||
248 | 470 | case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: | ||
249 | 471 | icon = "audio-volume-high"; | ||
250 | 472 | break; | ||
251 | 473 | case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: | ||
252 | 474 | icon = "audio-volume-high"; | ||
253 | 475 | break; | ||
254 | 476 | case VolumeControl.ActiveOutput.USB_SPEAKER: | ||
255 | 477 | icon = "audio-volume-high"; | ||
256 | 478 | break; | ||
257 | 479 | case VolumeControl.ActiveOutput.USB_HEADPHONES: | ||
258 | 480 | icon = "audio-volume-high"; | ||
259 | 481 | break; | ||
260 | 482 | case VolumeControl.ActiveOutput.HDMI_SPEAKER: | ||
261 | 483 | icon = "audio-volume-high"; | ||
262 | 484 | break; | ||
263 | 485 | case VolumeControl.ActiveOutput.HDMI_HEADPHONES: | ||
264 | 486 | icon = "audio-volume-high"; | ||
265 | 487 | break; | ||
266 | 488 | } | ||
267 | 489 | } else { | ||
268 | 490 | icon = get_volume_icon (volume, active_output); | ||
269 | 491 | } | ||
270 | 492 | return icon; | ||
271 | 493 | } | ||
272 | 494 | |||
273 | 495 | private string get_volume_root_icon (double volume, bool mute, VolumeControl.ActiveOutput active_output) { | ||
274 | 496 | string icon = ""; | ||
275 | 497 | switch (active_output) | ||
276 | 498 | { | ||
277 | 499 | case VolumeControl.ActiveOutput.SPEAKERS: | ||
278 | 500 | if (mute || volume <= 0.0) | ||
279 | 501 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
280 | 502 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
281 | 503 | icon = "audio-volume-muted-panel"; | ||
282 | 504 | else | ||
283 | 505 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
284 | 506 | break; | ||
285 | 507 | case VolumeControl.ActiveOutput.HEADPHONES: | ||
286 | 508 | if (mute || volume <= 0.0) | ||
287 | 509 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
288 | 510 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
289 | 511 | icon = "audio-volume-muted-panel"; | ||
290 | 512 | else | ||
291 | 513 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
292 | 514 | break; | ||
293 | 515 | case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: | ||
294 | 516 | if (mute || volume <= 0.0) | ||
295 | 517 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
296 | 518 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
297 | 519 | icon = "audio-volume-muted-panel"; | ||
298 | 520 | else | ||
299 | 521 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
300 | 522 | break; | ||
301 | 523 | case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: | ||
302 | 524 | if (mute || volume <= 0.0) | ||
303 | 525 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
304 | 526 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
305 | 527 | icon = "audio-volume-muted-panel"; | ||
306 | 528 | else | ||
307 | 529 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
308 | 530 | break; | ||
309 | 531 | case VolumeControl.ActiveOutput.USB_SPEAKER: | ||
310 | 532 | if (mute || volume <= 0.0) | ||
311 | 533 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
312 | 534 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
313 | 535 | icon = "audio-volume-muted-panel"; | ||
314 | 536 | else | ||
315 | 537 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
316 | 538 | break; | ||
317 | 539 | case VolumeControl.ActiveOutput.USB_HEADPHONES: | ||
318 | 540 | if (mute || volume <= 0.0) | ||
319 | 541 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
320 | 542 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
321 | 543 | icon = "audio-volume-muted-panel"; | ||
322 | 544 | else | ||
323 | 545 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
324 | 546 | break; | ||
325 | 547 | case VolumeControl.ActiveOutput.HDMI_SPEAKER: | ||
326 | 548 | if (mute || volume <= 0.0) | ||
327 | 549 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
328 | 550 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
329 | 551 | icon = "audio-volume-muted-panel"; | ||
330 | 552 | else | ||
331 | 553 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
332 | 554 | break; | ||
333 | 555 | case VolumeControl.ActiveOutput.HDMI_HEADPHONES: | ||
334 | 556 | if (mute || volume <= 0.0) | ||
335 | 557 | icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; | ||
336 | 558 | else if (this.accounts_service != null && this.accounts_service.silentMode) | ||
337 | 559 | icon = "audio-volume-muted-panel"; | ||
338 | 560 | else | ||
339 | 561 | icon = get_volume_root_icon_by_volume (volume, active_output); | ||
340 | 562 | break; | ||
341 | 563 | } | ||
342 | 564 | return icon; | ||
343 | 565 | } | ||
344 | 566 | |||
345 | 285 | private void update_notification () { | 567 | private void update_notification () { |
346 | 286 | 568 | ||
347 | 287 | if (!notify_server_caps_checked) { | 569 | if (!notify_server_caps_checked) { |
348 | @@ -323,26 +605,46 @@ | |||
349 | 323 | if (notify_server_supports_sync && !block_info_notifications) { | 605 | if (notify_server_supports_sync && !block_info_notifications) { |
350 | 324 | 606 | ||
351 | 325 | /* Determine Label */ | 607 | /* Determine Label */ |
353 | 326 | unowned string volume_label = loud | 608 | string volume_label = loud |
354 | 327 | ? _("High volume can damage your hearing.") | 609 | ? _("High volume can damage your hearing.") |
355 | 328 | : ""; | 610 | : ""; |
356 | 611 | |||
357 | 612 | if (volume_label == "") { | ||
358 | 613 | if (volume_control.active_output == VolumeControl.ActiveOutput.SPEAKERS) { | ||
359 | 614 | volume_label = _("Speakers"); | ||
360 | 615 | } | ||
361 | 616 | |||
362 | 617 | if (volume_control.active_output == VolumeControl.ActiveOutput.HEADPHONES) { | ||
363 | 618 | volume_label = _("Headphones"); | ||
364 | 619 | } | ||
365 | 620 | |||
366 | 621 | if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES) { | ||
367 | 622 | volume_label = _("Bluetooth headphones"); | ||
368 | 623 | } | ||
369 | 624 | |||
370 | 625 | if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER) { | ||
371 | 626 | volume_label = _("Bluetooth speaker"); | ||
372 | 627 | } | ||
373 | 628 | |||
374 | 629 | if (volume_control.active_output == VolumeControl.ActiveOutput.USB_SPEAKER) { | ||
375 | 630 | volume_label = _("Usb speaker"); | ||
376 | 631 | } | ||
377 | 632 | |||
378 | 633 | if (volume_control.active_output == VolumeControl.ActiveOutput.USB_HEADPHONES) { | ||
379 | 634 | volume_label = _("Usb headphones"); | ||
380 | 635 | } | ||
381 | 636 | |||
382 | 637 | if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_SPEAKER) { | ||
383 | 638 | volume_label = _("HDMI speaker"); | ||
384 | 639 | } | ||
385 | 640 | |||
386 | 641 | if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_HEADPHONES) { | ||
387 | 642 | volume_label = _("HDMI headphones"); | ||
388 | 643 | } | ||
389 | 644 | } | ||
390 | 329 | 645 | ||
391 | 330 | /* Choose an icon */ | 646 | /* Choose an icon */ |
407 | 331 | unowned string icon; | 647 | string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output); |
393 | 332 | if (loud) { | ||
394 | 333 | icon = "audio-volume-high"; | ||
395 | 334 | } else { | ||
396 | 335 | var volume = volume_control.volume.volume; | ||
397 | 336 | |||
398 | 337 | if (volume <= 0.0) | ||
399 | 338 | icon = "audio-volume-muted"; | ||
400 | 339 | else if (volume <= 0.3) | ||
401 | 340 | icon = "audio-volume-low"; | ||
402 | 341 | else if (volume <= 0.7) | ||
403 | 342 | icon = "audio-volume-medium"; | ||
404 | 343 | else | ||
405 | 344 | icon = "audio-volume-high"; | ||
406 | 345 | } | ||
408 | 346 | 648 | ||
409 | 347 | /* Reset the notification */ | 649 | /* Reset the notification */ |
410 | 348 | var n = this.info_notification; | 650 | var n = this.info_notification; |
411 | 349 | 651 | ||
412 | === modified file 'src/sound-menu.vala' | |||
413 | --- src/sound-menu.vala 2015-02-12 00:44:34 +0000 | |||
414 | +++ src/sound-menu.vala 2015-10-05 12:20:39 +0000 | |||
415 | @@ -71,6 +71,7 @@ | |||
416 | 71 | this.notify_handlers = new HashTable<MediaPlayer, ulong> (direct_hash, direct_equal); | 71 | this.notify_handlers = new HashTable<MediaPlayer, ulong> (direct_hash, direct_equal); |
417 | 72 | 72 | ||
418 | 73 | this.greeter_players = (flags & DisplayFlags.GREETER_PLAYERS) != 0; | 73 | this.greeter_players = (flags & DisplayFlags.GREETER_PLAYERS) != 0; |
419 | 74 | |||
420 | 74 | } | 75 | } |
421 | 75 | 76 | ||
422 | 76 | ~SoundMenu () { | 77 | ~SoundMenu () { |
423 | @@ -185,6 +186,28 @@ | |||
424 | 185 | this.notify_handlers.remove (player); | 186 | this.notify_handlers.remove (player); |
425 | 186 | } | 187 | } |
426 | 187 | 188 | ||
427 | 189 | public void update_volume_slider (VolumeControl.ActiveOutput active_output) { | ||
428 | 190 | int index = find_action (this.volume_section, "indicator.volume"); | ||
429 | 191 | if (index != -1) { | ||
430 | 192 | string label = "Volume"; | ||
431 | 193 | switch (active_output) { | ||
432 | 194 | case VolumeControl.ActiveOutput.SPEAKERS: | ||
433 | 195 | label = "Volume"; | ||
434 | 196 | break; | ||
435 | 197 | case VolumeControl.ActiveOutput.HEADPHONES: | ||
436 | 198 | label = "Volume (Headphones)"; | ||
437 | 199 | break; | ||
438 | 200 | case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: | ||
439 | 201 | label = "Volume (Bluetooth)"; | ||
440 | 202 | break; | ||
441 | 203 | } | ||
442 | 204 | this.volume_section.remove (index); | ||
443 | 205 | this.volume_section.insert_item (index, this.create_slider_menu_item (_(label), "indicator.volume(0)", 0.0, 1.0, 0.01, | ||
444 | 206 | "audio-volume-low-zero-panel", | ||
445 | 207 | "audio-volume-high-panel")); | ||
446 | 208 | } | ||
447 | 209 | } | ||
448 | 210 | |||
449 | 188 | public Menu root; | 211 | public Menu root; |
450 | 189 | public Menu menu; | 212 | public Menu menu; |
451 | 190 | Menu volume_section; | 213 | Menu volume_section; |
452 | 191 | 214 | ||
453 | === modified file 'src/volume-control-pulse.vala' | |||
454 | --- src/volume-control-pulse.vala 2015-08-12 18:16:40 +0000 | |||
455 | +++ src/volume-control-pulse.vala 2015-10-05 12:20:39 +0000 | |||
456 | @@ -87,6 +87,7 @@ | |||
457 | 87 | private bool _send_next_local_volume = false; | 87 | private bool _send_next_local_volume = false; |
458 | 88 | private double _account_service_volume = 0.0; | 88 | private double _account_service_volume = 0.0; |
459 | 89 | private bool _active_port_headphone = false; | 89 | private bool _active_port_headphone = false; |
460 | 90 | private VolumeControl.ActiveOutput _active_output = VolumeControl.ActiveOutput.SPEAKERS; | ||
461 | 90 | 91 | ||
462 | 91 | /** true when connected to the pulse server */ | 92 | /** true when connected to the pulse server */ |
463 | 92 | public override bool ready { get; private set; } | 93 | public override bool ready { get; private set; } |
464 | @@ -135,6 +136,52 @@ | |||
465 | 135 | stop_high_volume_approved_timer(); | 136 | stop_high_volume_approved_timer(); |
466 | 136 | } | 137 | } |
467 | 137 | 138 | ||
468 | 139 | private VolumeControl.ActiveOutput calculate_active_output (SinkInfo? sink) { | ||
469 | 140 | |||
470 | 141 | VolumeControl.ActiveOutput ret_output = VolumeControl.ActiveOutput.SPEAKERS; | ||
471 | 142 | /* Check if the current active port is headset/headphone */ | ||
472 | 143 | /* There is not easy way to check if the port is a headset/headphone besides | ||
473 | 144 | * checking for the port name. On touch (with the pulseaudio droid element) | ||
474 | 145 | * the headset/headphone port is called 'output-headset' and 'output-headphone'. | ||
475 | 146 | * On the desktop this is usually called 'analog-output-headphones' */ | ||
476 | 147 | if (sink.active_port != null) { | ||
477 | 148 | // look if it's a headset/headphones | ||
478 | 149 | if (sink.active_port.name.contains("headset") || | ||
479 | 150 | sink.active_port.name.contains("headphone")) { | ||
480 | 151 | _active_port_headphone = true; | ||
481 | 152 | // check if it's a bluetooth device | ||
482 | 153 | var device_bus = sink.proplist.gets ("device.bus"); | ||
483 | 154 | if (device_bus != null && device_bus == "bluetooth") { | ||
484 | 155 | ret_output = VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES; | ||
485 | 156 | } else if (device_bus != null && device_bus == "usb") { | ||
486 | 157 | ret_output = VolumeControl.ActiveOutput.USB_HEADPHONES; | ||
487 | 158 | } else if (device_bus != null && device_bus == "hdmi") { | ||
488 | 159 | ret_output = VolumeControl.ActiveOutput.HDMI_HEADPHONES; | ||
489 | 160 | } else { | ||
490 | 161 | ret_output = VolumeControl.ActiveOutput.HEADPHONES; | ||
491 | 162 | } | ||
492 | 163 | } else { | ||
493 | 164 | // speaker | ||
494 | 165 | _active_port_headphone = false; | ||
495 | 166 | var device_bus = sink.proplist.gets ("device.bus"); | ||
496 | 167 | if (device_bus != null && device_bus == "bluetooth") { | ||
497 | 168 | ret_output = VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER; | ||
498 | 169 | } else if (device_bus != null && device_bus == "usb") { | ||
499 | 170 | ret_output = VolumeControl.ActiveOutput.USB_SPEAKER; | ||
500 | 171 | } else if (device_bus != null && device_bus == "hdmi") { | ||
501 | 172 | ret_output = VolumeControl.ActiveOutput.HDMI_SPEAKER; | ||
502 | 173 | } else { | ||
503 | 174 | ret_output = VolumeControl.ActiveOutput.SPEAKERS; | ||
504 | 175 | } | ||
505 | 176 | } | ||
506 | 177 | } else { | ||
507 | 178 | _active_port_headphone = false; | ||
508 | 179 | ret_output = VolumeControl.ActiveOutput.SPEAKERS; | ||
509 | 180 | } | ||
510 | 181 | |||
511 | 182 | return ret_output; | ||
512 | 183 | } | ||
513 | 184 | |||
514 | 138 | /* PulseAudio logic*/ | 185 | /* PulseAudio logic*/ |
515 | 139 | private void context_events_cb (Context c, Context.SubscriptionEventType t, uint32 index) | 186 | private void context_events_cb (Context c, Context.SubscriptionEventType t, uint32 index) |
516 | 140 | { | 187 | { |
517 | @@ -201,18 +248,20 @@ | |||
518 | 201 | this.notify_property ("is-playing"); | 248 | this.notify_property ("is-playing"); |
519 | 202 | } | 249 | } |
520 | 203 | 250 | ||
533 | 204 | /* Check if the current active port is headset/headphone */ | 251 | // store the current status of the active output |
534 | 205 | /* There is not easy way to check if the port is a headset/headphone besides | 252 | VolumeControl.ActiveOutput active_output_before = active_output; |
535 | 206 | * checking for the port name. On touch (with the pulseaudio droid element) | 253 | |
536 | 207 | * the headset/headphone port is called 'output-headset' and 'output-headphone'. | 254 | // calculate the output |
537 | 208 | * On the desktop this is usually called 'analog-output-headphones' */ | 255 | _active_output = calculate_active_output (i); |
538 | 209 | if (i.active_port != null && | 256 | |
539 | 210 | (i.active_port.name == "output-wired_headset" || | 257 | // check if the output has changed, if so... emit a signal |
540 | 211 | i.active_port.name == "output-wired_headphone" || | 258 | VolumeControl.ActiveOutput active_output_now = active_output; |
541 | 212 | i.active_port.name == "analog-output-headphones")) { | 259 | if (active_output_now != active_output_before) { |
542 | 213 | _active_port_headphone = true; | 260 | this.active_output_changed (active_output_now); |
543 | 214 | } else { | 261 | if (active_output_now == VolumeControl.ActiveOutput.SPEAKERS) { |
544 | 215 | _active_port_headphone = false; | 262 | _high_volume_approved = false; |
545 | 263 | } | ||
546 | 264 | update_high_volume(); | ||
547 | 216 | } | 265 | } |
548 | 217 | 266 | ||
549 | 218 | if (_pulse_use_stream_restore == false && | 267 | if (_pulse_use_stream_restore == false && |
550 | @@ -535,6 +584,14 @@ | |||
551 | 535 | } | 584 | } |
552 | 536 | } | 585 | } |
553 | 537 | 586 | ||
554 | 587 | public override VolumeControl.ActiveOutput active_output | ||
555 | 588 | { | ||
556 | 589 | get | ||
557 | 590 | { | ||
558 | 591 | return _active_output; | ||
559 | 592 | } | ||
560 | 593 | } | ||
561 | 594 | |||
562 | 538 | /* Volume operations */ | 595 | /* Volume operations */ |
563 | 539 | private static PulseAudio.Volume double_to_volume (double vol) | 596 | private static PulseAudio.Volume double_to_volume (double vol) |
564 | 540 | { | 597 | { |
565 | 541 | 598 | ||
566 | === modified file 'src/volume-control.vala' | |||
567 | --- src/volume-control.vala 2015-08-12 14:00:56 +0000 | |||
568 | +++ src/volume-control.vala 2015-10-05 12:20:39 +0000 | |||
569 | @@ -28,6 +28,17 @@ | |||
570 | 28 | VOLUME_STREAM_CHANGE | 28 | VOLUME_STREAM_CHANGE |
571 | 29 | } | 29 | } |
572 | 30 | 30 | ||
573 | 31 | public enum ActiveOutput { | ||
574 | 32 | SPEAKERS, | ||
575 | 33 | HEADPHONES, | ||
576 | 34 | BLUETOOTH_HEADPHONES, | ||
577 | 35 | BLUETOOTH_SPEAKER, | ||
578 | 36 | USB_SPEAKER, | ||
579 | 37 | USB_HEADPHONES, | ||
580 | 38 | HDMI_SPEAKER, | ||
581 | 39 | HDMI_HEADPHONES | ||
582 | 40 | } | ||
583 | 41 | |||
584 | 31 | public class Volume : Object { | 42 | public class Volume : Object { |
585 | 32 | public double volume; | 43 | public double volume; |
586 | 33 | public VolumeReasons reason; | 44 | public VolumeReasons reason; |
587 | @@ -39,6 +50,7 @@ | |||
588 | 39 | public virtual bool high_volume { get { return false; } protected set { } } | 50 | public virtual bool high_volume { get { return false; } protected set { } } |
589 | 40 | public virtual bool mute { get { return false; } } | 51 | public virtual bool mute { get { return false; } } |
590 | 41 | public virtual bool is_playing { get { return false; } } | 52 | public virtual bool is_playing { get { return false; } } |
591 | 53 | public virtual VolumeControl.ActiveOutput active_output { get { return VolumeControl.ActiveOutput.SPEAKERS; } } | ||
592 | 42 | private Volume _volume; | 54 | private Volume _volume; |
593 | 43 | public virtual Volume volume { get { return _volume; } set { } } | 55 | public virtual Volume volume { get { return _volume; } set { } } |
594 | 44 | public virtual double mic_volume { get { return 0.0; } set { } } | 56 | public virtual double mic_volume { get { return 0.0; } set { } } |
595 | @@ -56,4 +68,6 @@ | |||
596 | 56 | v.reason = reason; | 68 | v.reason = reason; |
597 | 57 | this.volume = v; | 69 | this.volume = v; |
598 | 58 | } | 70 | } |
599 | 71 | |||
600 | 72 | public signal void active_output_changed (VolumeControl.ActiveOutput active_output); | ||
601 | 59 | } | 73 | } |
602 | 60 | 74 | ||
603 | === modified file 'tests/notifications-test.cc' | |||
604 | --- tests/notifications-test.cc 2015-08-11 22:19:36 +0000 | |||
605 | +++ tests/notifications-test.cc 2015-10-05 12:20:39 +0000 | |||
606 | @@ -345,7 +345,7 @@ | |||
607 | 345 | auto notev = notifications->getNotifications(); | 345 | auto notev = notifications->getNotifications(); |
608 | 346 | ASSERT_EQ(1, notev.size()); | 346 | ASSERT_EQ(1, notev.size()); |
609 | 347 | EXPECT_EQ("Volume", notev[0].summary); | 347 | EXPECT_EQ("Volume", notev[0].summary); |
611 | 348 | EXPECT_EQ("", notev[0].body); | 348 | EXPECT_EQ("Speakers", notev[0].body); |
612 | 349 | EXPECT_GVARIANT_EQ("@s 'false'", notev[0].hints["x-canonical-value-bar-tint"]); | 349 | EXPECT_GVARIANT_EQ("@s 'false'", notev[0].hints["x-canonical-value-bar-tint"]); |
613 | 350 | 350 | ||
614 | 351 | /* Set high volume with volume change */ | 351 | /* Set high volume with volume change */ |
PASSED: Continuous integration, rev:506 jenkins. qa.ubuntu. com/job/ indicator- sound-ci/ 257/ jenkins. qa.ubuntu. com/job/ indicator- sound-wily- amd64-ci/ 33 jenkins. qa.ubuntu. com/job/ indicator- sound-wily- armhf-ci/ 33 jenkins. qa.ubuntu. com/job/ indicator- sound-wily- armhf-ci/ 33/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/indicator- sound-ci/ 257/rebuild
http://