Merge lp:~djaler1/switchboard-plug-bluetooth/fix-1650923 into lp:~elementary-pantheon/switchboard-plug-bluetooth/trunk

Proposed by Kirill Romanov
Status: Merged
Approved by: Danielle Foré
Approved revision: 32
Merged at revision: 32
Proposed branch: lp:~djaler1/switchboard-plug-bluetooth/fix-1650923
Merge into: lp:~elementary-pantheon/switchboard-plug-bluetooth/trunk
Diff against target: 59 lines (+16/-4)
2 files modified
src/DeviceRow.vala (+12/-2)
src/MainView.vala (+4/-2)
To merge this branch: bzr merge lp:~djaler1/switchboard-plug-bluetooth/fix-1650923
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+313925@code.launchpad.net

Commit message

Make devicerow insensitive if its adapater is off

Description of the change

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Works for me! nice job :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/DeviceRow.vala'
2--- src/DeviceRow.vala 2016-12-19 00:14:04 +0000
3+++ src/DeviceRow.vala 2016-12-30 23:11:51 +0000
4@@ -20,6 +20,7 @@
5
6 public class Bluetooth.DeviceRow : Gtk.ListBoxRow {
7 public Services.Device device { get; construct; }
8+ public unowned Services.Adapter adapter { get; construct; }
9 private static Gtk.SizeGroup size_group;
10
11 private enum Status {
12@@ -49,8 +50,8 @@
13 private Gtk.Image state;
14 private Gtk.Label state_label;
15
16- public DeviceRow (Services.Device device) {
17- Object (device: device);
18+ public DeviceRow (Services.Device device, Services.Adapter adapter) {
19+ Object (device: device, adapter: adapter);
20 }
21
22 static construct {
23@@ -132,6 +133,15 @@
24 set_status (Status.NOT_CONNECTED);
25 }
26
27+ set_sensitive (adapter.powered);
28+
29+ (adapter as DBusProxy).g_properties_changed.connect ((changed, invalid) => {
30+ var powered = changed.lookup_value ("Powered", new VariantType ("b"));
31+ if (powered != null) {
32+ set_sensitive (adapter.powered);
33+ }
34+ });
35+
36 (device as DBusProxy).g_properties_changed.connect ((changed, invalid) => {
37 var connected = changed.lookup_value ("Connected", new VariantType ("b"));
38 if (connected != null) {
39
40=== modified file 'src/MainView.vala'
41--- src/MainView.vala 2016-12-17 17:29:29 +0000
42+++ src/MainView.vala 2016-12-30 23:11:51 +0000
43@@ -27,12 +27,14 @@
44 this.manager = manager;
45
46 foreach (var device in manager.get_devices ()) {
47- var row = new DeviceRow (device);
48+ var adapter = manager.get_adapter_from_path (device.adapter);
49+ var row = new DeviceRow (device, adapter);
50 list_box.add (row);
51 }
52
53 manager.device_added.connect ((device) => {
54- var row = new DeviceRow (device);
55+ var adapter = manager.get_adapter_from_path (device.adapter);
56+ var row = new DeviceRow (device, adapter);
57 list_box.add (row);
58 if (list_box.get_selected_row () == null) {
59 list_box.select_row (row);

Subscribers

People subscribed via source and target branches

to all changes: