Skip to content

Commit 0a2d54f

Browse files
authored
DeviceRow: get adapter internally (#241)
1 parent 2c75457 commit 0a2d54f

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/DeviceRow.vala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
*/
2020

2121
public class Bluetooth.DeviceRow : Gtk.ListBoxRow {
22+
public signal void status_changed ();
23+
2224
public Services.Device device { get; construct; }
23-
public unowned Services.Adapter adapter { get; construct; }
24-
private static Gtk.SizeGroup size_group;
2525

26-
public signal void status_changed ();
26+
private static Gtk.SizeGroup size_group;
2727

2828
private enum Status {
2929
UNPAIRED,
@@ -62,8 +62,8 @@ public class Bluetooth.DeviceRow : Gtk.ListBoxRow {
6262
private Gtk.Label state_label;
6363
private Gtk.LinkButton settings_button;
6464

65-
public DeviceRow (Services.Device device, Services.Adapter adapter) {
66-
Object (device: device, adapter: adapter);
65+
public DeviceRow (Services.Device device) {
66+
Object (device: device);
6767
}
6868

6969
static construct {
@@ -187,6 +187,8 @@ public class Bluetooth.DeviceRow : Gtk.ListBoxRow {
187187
break;
188188
}
189189

190+
var adapter = Services.ObjectManager.get_default ().get_adapter_from_path (device.adapter);
191+
190192
compute_status ();
191193
set_sensitive (adapter.powered);
192194

src/MainView.vala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ public class Bluetooth.MainView : Switchboard.SettingsPage {
8383

8484
private void complete_setup () {
8585
foreach (var device in manager.get_devices ()) {
86-
var adapter = manager.get_adapter_from_path (device.adapter);
87-
var row = new DeviceRow (device, adapter);
86+
var row = new DeviceRow (device);
8887
list_box.append (row);
8988
}
9089

@@ -100,8 +99,7 @@ public class Bluetooth.MainView : Switchboard.SettingsPage {
10099

101100
/* Now retrieve finished, we can connect manager signals */
102101
manager.device_added.connect ((device) => {
103-
var adapter = manager.get_adapter_from_path (device.adapter);
104-
var row = new DeviceRow (device, adapter);
102+
var row = new DeviceRow (device);
105103
list_box.append (row);
106104
if (list_box.get_selected_row () == null) {
107105
list_box.select_row (row);

0 commit comments

Comments
 (0)