Skip to content

Commit

Permalink
xfce-bluetooth: delete device when pressing button
Browse files Browse the repository at this point in the history
  • Loading branch information
ncopa committed Aug 16, 2013
1 parent e11db9f commit 7330bdc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/xfce-bluetooth.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class XfceBluetoothApp : GLib.Object {

string? selected_device = null;
Button device_remove_button;
TreeView device_treeview;

DBusObjectManager manager;
BluezAdapterProperties adapter;
Expand Down Expand Up @@ -116,7 +117,7 @@ public class XfceBluetoothApp : GLib.Object {

find_devices();

TreeView device_treeview = builder.get_object("device_treeview") as TreeView;
device_treeview = builder.get_object("device_treeview") as TreeView;
device_treeview.set_model(device_store);

var text = new CellRendererText();
Expand Down Expand Up @@ -175,6 +176,15 @@ public class XfceBluetoothApp : GLib.Object {
[CCode (instance_pos = -1)]
public void on_remove(Button button) {
stdout.printf("Remove %s\n", selected_device);
TreeSelection selection = device_treeview.get_selection();
TreeModel model;
TreeIter iter;
if (selection.get_selected(out model, out iter)) {
Value objpath = Value(typeof(string));
model.get_value(iter, DevCols.OBJPATH, out objpath);
adapter.remove_device(new ObjectPath(objpath.get_string()));
device_store.remove(iter);
}
}

[CCode (instance_pos = -1)]
Expand Down

0 comments on commit 7330bdc

Please sign in to comment.