Merge lp:~charlesk/indicator-bluetooth/lp-1126108 into lp:indicator-bluetooth/14.04

Proposed by Charles Kerr
Status: Merged
Approved by: Lars Karlitski
Approved revision: 81
Merged at revision: 77
Proposed branch: lp:~charlesk/indicator-bluetooth/lp-1126108
Merge into: lp:indicator-bluetooth/14.04
Diff against target: 143 lines (+37/-7)
4 files modified
src/bluetooth.vala (+3/-0)
src/bluez.vala (+22/-1)
src/desktop.vala (+2/-2)
src/profile.vala (+10/-4)
To merge this branch: bzr merge lp:~charlesk/indicator-bluetooth/lp-1126108
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Lars Karlitski (community) Approve
Review via email: mp+198095@code.launchpad.net

Description of the change

Gets us a little closer to the spec in two ways:

1. Indicator Visibility

On the desktop, the indicator's header icon is visible whenever a default adapter is available (whether the adapter is powered or not) and the user's preference settings call for a visible Bluetooth indicator.

On the phone, the indicator's header icon is visible whenever a default adapter is available *and* the adapter is powered.

2. Header Icon

If Bluetooth is off, the header icon now uses the "bluetooth-disabled" icon.
If Bluetooth is on, it now uses the "bluetooth-active" icon.
If Bluetooth is on and has a connected device, it now uses the "bluetooth-paired" icon.

To post a comment you must log in.
Revision history for this message
Lars Karlitski (larsu) wrote :

Sounds about right ;)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/bluetooth.vala'
--- src/bluetooth.vala 2013-10-11 13:38:51 +0000
+++ src/bluetooth.vala 2013-12-06 16:45:24 +0000
@@ -32,6 +32,9 @@
32 eg by a laptop's network killswitch */32 eg by a laptop's network killswitch */
33 public abstract bool enabled { get; protected set; }33 public abstract bool enabled { get; protected set; }
3434
35 /* True if we have a connected device. */
36 public abstract bool connected { get; protected set; }
37
35 /* Try to enable/disable bluetooth. This can fail if it's overridden38 /* Try to enable/disable bluetooth. This can fail if it's overridden
36 by the system, eg by a laptop's network killswitch */39 by the system, eg by a laptop's network killswitch */
37 public abstract void try_set_enabled (bool b);40 public abstract void try_set_enabled (bool b);
3841
=== modified file 'src/bluez.vala'
--- src/bluez.vala 2013-10-14 23:33:59 +0000
+++ src/bluez.vala 2013-12-06 16:45:24 +0000
@@ -157,6 +157,8 @@
157 critical (@"$(e.message)");157 critical (@"$(e.message)");
158 }158 }
159159
160 supported = object_path != null;
161
160 on_default_adapter_properties_changed ();162 on_default_adapter_properties_changed ();
161 }163 }
162164
@@ -414,6 +416,7 @@
414 supports_file_transfer));416 supports_file_transfer));
415417
416 devices_changed ();418 devices_changed ();
419 update_connected ();
417 }420 }
418421
419 /* update the 'enabled' property by looking at the killswitch state422 /* update the 'enabled' property by looking at the killswitch state
@@ -424,7 +427,22 @@
424 debug (@"in upate_enabled, powered is $powered, blocked is $blocked");427 debug (@"in upate_enabled, powered is $powered, blocked is $blocked");
425 enabled = powered && !blocked;428 enabled = powered && !blocked;
426 }429 }
427 430
431 private bool have_connected_device ()
432 {
433 var devices = get_devices();
434
435 foreach (var device in devices)
436 if (device.is_connected)
437 return true;
438
439 return false;
440 }
441
442 private void update_connected ()
443 {
444 connected = have_connected_device ();
445 }
428446
429 ////447 ////
430 //// Public API448 //// Public API
@@ -444,6 +462,8 @@
444 device_connect (proxy);462 device_connect (proxy);
445 else463 else
446 device_disconnect (proxy);464 device_disconnect (proxy);
465
466 update_connected ();
447 }467 }
448 }468 }
449469
@@ -463,6 +483,7 @@
463 public bool supported { get; protected set; default = false; }483 public bool supported { get; protected set; default = false; }
464 public bool discoverable { get; protected set; default = false; }484 public bool discoverable { get; protected set; default = false; }
465 public bool enabled { get; protected set; default = false; }485 public bool enabled { get; protected set; default = false; }
486 public bool connected { get; protected set; default = false; }
466487
467 public void try_set_enabled (bool b)488 public void try_set_enabled (bool b)
468 {489 {
469490
=== modified file 'src/desktop.vala'
--- src/desktop.vala 2013-10-25 00:19:20 +0000
+++ src/desktop.vala 2013-12-06 16:45:24 +0000
@@ -66,7 +66,7 @@
6666
67 // know when to show the indicator & when to hide it67 // know when to show the indicator & when to hide it
68 settings.changed["visible"].connect (()=> update_visibility());68 settings.changed["visible"].connect (()=> update_visibility());
69 bluetooth.notify["enabled"].connect (() => update_visibility());69 bluetooth.notify["supported"].connect (() => update_visibility());
70 update_visibility ();70 update_visibility ();
7171
72 // when devices change, rebuild our device section72 // when devices change, rebuild our device section
@@ -82,7 +82,7 @@
8282
83 void update_visibility ()83 void update_visibility ()
84 {84 {
85 visible = bluetooth.enabled && settings.get_boolean("visible");85 visible = bluetooth.supported && settings.get_boolean("visible");
86 }86 }
8787
88 ///88 ///
8989
=== modified file 'src/profile.vala'
--- src/profile.vala 2013-10-25 00:19:20 +0000
+++ src/profile.vala 2013-12-06 16:45:24 +0000
@@ -37,7 +37,8 @@
37 null,37 null,
38 action_state_for_root());38 action_state_for_root());
39 notify["visible"].connect (() => update_root_action_state());39 notify["visible"].connect (() => update_root_action_state());
4040 bluetooth.notify["enabled"].connect (() => update_root_action_state());
41 bluetooth.notify["connected"].connect (() => update_root_action_state());
41 menu = new Menu ();42 menu = new Menu ();
4243
43 var item = create_root_menuitem ();44 var item = create_root_menuitem ();
@@ -85,7 +86,7 @@
8586
86 protected MenuItem create_enabled_menuitem ()87 protected MenuItem create_enabled_menuitem ()
87 {88 {
88 var item = new MenuItem ("Bluetooth", "indicator.bluetooth-enabled");89 var item = new MenuItem (_("Bluetooth"), "indicator.bluetooth-enabled");
8990
90 item.set_attribute ("x-canonical-type", "s",91 item.set_attribute ("x-canonical-type", "s",
91 "com.canonical.indicator.switch");92 "com.canonical.indicator.switch");
@@ -146,7 +147,13 @@
146 {147 {
147 string a11y;148 string a11y;
148 string icon_name;149 string icon_name;
149 if (bluetooth.enabled)150
151 if (bluetooth.connected)
152 {
153 a11y = "Bluetooth (connections)";
154 icon_name = "bluetooth-paired";
155 }
156 else if (bluetooth.enabled)
150 {157 {
151 a11y = "Bluetooth (on)";158 a11y = "Bluetooth (on)";
152 icon_name = "bluetooth-active";159 icon_name = "bluetooth-active";
@@ -158,7 +165,6 @@
158 }165 }
159166
160 var icon = new ThemedIcon.with_default_fallbacks (icon_name);167 var icon = new ThemedIcon.with_default_fallbacks (icon_name);
161
162 var builder = new VariantBuilder (new VariantType ("a{sv}"));168 var builder = new VariantBuilder (new VariantType ("a{sv}"));
163 builder.add ("{sv}", "visible", new Variant.boolean (visible));169 builder.add ("{sv}", "visible", new Variant.boolean (visible));
164 builder.add ("{sv}", "accessible-desc", new Variant.string (a11y));170 builder.add ("{sv}", "accessible-desc", new Variant.string (a11y));

Subscribers

People subscribed via source and target branches