Skip to content

Commit be69bea

Browse files
authored
DeviceRow: connect to activate (#243)
1 parent 0a2d54f commit be69bea

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/DeviceRow.vala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,7 @@ public class Bluetooth.DeviceRow : Gtk.ListBoxRow {
225225
}
226226
});
227227

228-
connect_button.clicked.connect (() => {
229-
button_clicked.begin ();
230-
// If pairing is successful, mark devices as trusted so they autoconnect
231-
device.trusted = device.paired;
232-
});
228+
connect_button.clicked.connect (() => on_activate.begin ());
233229

234230
forget_button.clicked.connect (() => {
235231
try {
@@ -241,11 +237,13 @@ public class Bluetooth.DeviceRow : Gtk.ListBoxRow {
241237

242238
}
243239

244-
private async void button_clicked () {
240+
public async void on_activate () {
245241
if (!device.paired) {
246242
set_status (Status.PAIRING);
247243
try {
248244
yield device.pair ();
245+
// If pairing is successful, mark devices as trusted so they autoconnect
246+
device.trusted = device.paired;
249247
} catch (Error e) {
250248
set_status (Status.UNABLE_TO_CONNECT);
251249
critical (e.message);

src/MainView.vala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ public class Bluetooth.MainView : Switchboard.SettingsPage {
4141
description = _("Please ensure that your devices are visible and ready for pairing.")
4242
};
4343

44-
list_box = new Gtk.ListBox ();
44+
list_box = new Gtk.ListBox () {
45+
activate_on_single_click = false,
46+
selection_mode = BROWSE
47+
};
4548
list_box.add_css_class (Granite.STYLE_CLASS_RICH_LIST);
4649
list_box.set_sort_func ((Gtk.ListBoxSortFunc) compare_rows);
4750
list_box.set_header_func ((Gtk.ListBoxUpdateHeaderFunc) title_rows);
4851
list_box.set_placeholder (empty_alert);
49-
list_box.selection_mode = Gtk.SelectionMode.BROWSE;
50-
list_box.activate_on_single_click = true;
5152

5253
var scrolled = new Gtk.ScrolledWindow () {
5354
child = list_box,
@@ -76,6 +77,10 @@ public class Bluetooth.MainView : Switchboard.SettingsPage {
7677
manager.notify["retrieve-finished"].connect (complete_setup);
7778
}
7879

80+
list_box.row_activated.connect ((row) => {
81+
((DeviceRow) row).on_activate.begin ();
82+
});
83+
7984
status_switch.notify["active"].connect (() => {
8085
manager.set_global_state.begin (status_switch.active);
8186
});

0 commit comments

Comments
 (0)