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
1=== modified file 'src/bluetooth.vala'
2--- src/bluetooth.vala 2013-10-11 13:38:51 +0000
3+++ src/bluetooth.vala 2013-12-06 16:45:24 +0000
4@@ -32,6 +32,9 @@
5 eg by a laptop's network killswitch */
6 public abstract bool enabled { get; protected set; }
7
8+ /* True if we have a connected device. */
9+ public abstract bool connected { get; protected set; }
10+
11 /* Try to enable/disable bluetooth. This can fail if it's overridden
12 by the system, eg by a laptop's network killswitch */
13 public abstract void try_set_enabled (bool b);
14
15=== modified file 'src/bluez.vala'
16--- src/bluez.vala 2013-10-14 23:33:59 +0000
17+++ src/bluez.vala 2013-12-06 16:45:24 +0000
18@@ -157,6 +157,8 @@
19 critical (@"$(e.message)");
20 }
21
22+ supported = object_path != null;
23+
24 on_default_adapter_properties_changed ();
25 }
26
27@@ -414,6 +416,7 @@
28 supports_file_transfer));
29
30 devices_changed ();
31+ update_connected ();
32 }
33
34 /* update the 'enabled' property by looking at the killswitch state
35@@ -424,7 +427,22 @@
36 debug (@"in upate_enabled, powered is $powered, blocked is $blocked");
37 enabled = powered && !blocked;
38 }
39-
40+
41+ private bool have_connected_device ()
42+ {
43+ var devices = get_devices();
44+
45+ foreach (var device in devices)
46+ if (device.is_connected)
47+ return true;
48+
49+ return false;
50+ }
51+
52+ private void update_connected ()
53+ {
54+ connected = have_connected_device ();
55+ }
56
57 ////
58 //// Public API
59@@ -444,6 +462,8 @@
60 device_connect (proxy);
61 else
62 device_disconnect (proxy);
63+
64+ update_connected ();
65 }
66 }
67
68@@ -463,6 +483,7 @@
69 public bool supported { get; protected set; default = false; }
70 public bool discoverable { get; protected set; default = false; }
71 public bool enabled { get; protected set; default = false; }
72+ public bool connected { get; protected set; default = false; }
73
74 public void try_set_enabled (bool b)
75 {
76
77=== modified file 'src/desktop.vala'
78--- src/desktop.vala 2013-10-25 00:19:20 +0000
79+++ src/desktop.vala 2013-12-06 16:45:24 +0000
80@@ -66,7 +66,7 @@
81
82 // know when to show the indicator & when to hide it
83 settings.changed["visible"].connect (()=> update_visibility());
84- bluetooth.notify["enabled"].connect (() => update_visibility());
85+ bluetooth.notify["supported"].connect (() => update_visibility());
86 update_visibility ();
87
88 // when devices change, rebuild our device section
89@@ -82,7 +82,7 @@
90
91 void update_visibility ()
92 {
93- visible = bluetooth.enabled && settings.get_boolean("visible");
94+ visible = bluetooth.supported && settings.get_boolean("visible");
95 }
96
97 ///
98
99=== modified file 'src/profile.vala'
100--- src/profile.vala 2013-10-25 00:19:20 +0000
101+++ src/profile.vala 2013-12-06 16:45:24 +0000
102@@ -37,7 +37,8 @@
103 null,
104 action_state_for_root());
105 notify["visible"].connect (() => update_root_action_state());
106-
107+ bluetooth.notify["enabled"].connect (() => update_root_action_state());
108+ bluetooth.notify["connected"].connect (() => update_root_action_state());
109 menu = new Menu ();
110
111 var item = create_root_menuitem ();
112@@ -85,7 +86,7 @@
113
114 protected MenuItem create_enabled_menuitem ()
115 {
116- var item = new MenuItem ("Bluetooth", "indicator.bluetooth-enabled");
117+ var item = new MenuItem (_("Bluetooth"), "indicator.bluetooth-enabled");
118
119 item.set_attribute ("x-canonical-type", "s",
120 "com.canonical.indicator.switch");
121@@ -146,7 +147,13 @@
122 {
123 string a11y;
124 string icon_name;
125- if (bluetooth.enabled)
126+
127+ if (bluetooth.connected)
128+ {
129+ a11y = "Bluetooth (connections)";
130+ icon_name = "bluetooth-paired";
131+ }
132+ else if (bluetooth.enabled)
133 {
134 a11y = "Bluetooth (on)";
135 icon_name = "bluetooth-active";
136@@ -158,7 +165,6 @@
137 }
138
139 var icon = new ThemedIcon.with_default_fallbacks (icon_name);
140-
141 var builder = new VariantBuilder (new VariantType ("a{sv}"));
142 builder.add ("{sv}", "visible", new Variant.boolean (visible));
143 builder.add ("{sv}", "accessible-desc", new Variant.string (a11y));

Subscribers

People subscribed via source and target branches