From aab340eaa6787fbeabb3534c566d650ef8ae58fe Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Tue, 8 Aug 2017 15:58:51 +0200 Subject: [PATCH] WelcomePerspective: add methods to add and remove devices --- piper/welcomeperspective.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/piper/welcomeperspective.py b/piper/welcomeperspective.py index a20dea8..33b2e95 100644 --- a/piper/welcomeperspective.py +++ b/piper/welcomeperspective.py @@ -50,7 +50,24 @@ class WelcomePerspective(Gtk.Box): """ self.listbox.foreach(Gtk.Widget.destroy) for device in devices: - self.listbox.add(DeviceRow(device)) + self.add_device(device) + + def add_device(self, device): + """Add a device to the list. + + @param device The device to add, as ratbagd.RatbagdDevice + """ + self.listbox.add(DeviceRow(device)) + + def remove_device(self, device): + """Remove a device from the list. + + @param device The device to remove, as ratbagd.RatbagdDevice + """ + for child in self.listbox.get_children(): + if child._device is device: + child.destroy() + break @GObject.Property def name(self):