[gnome-bluetooth/wip/hadess/bluetoothd-restart: 1/3] settings-widget: Fix duplicate device when bluetoothd restarts




commit 00406d20fce16038ba2ee6a5f49af8a4235c073e
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 23 14:27:06 2022 +0200

    settings-widget: Fix duplicate device when bluetoothd restarts
    
    As recommended in the BluetoothClient documentation:
    "
     Note that #BluetoothClient::device-removed will not be called
     for each individual device as the model is cleared when the
     #BluetoothClient:default-adapter property changes.
    "
    
    Closes: #116

 lib/bluetooth-settings-widget.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index 3fd3b251..462f65bc 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -1341,6 +1341,14 @@ default_adapter_changed (BluetoothClient         *client,
 
        g_debug ("Default adapter changed to: %s", default_adapter ? default_adapter : "(none)");
 
+       if (default_adapter == NULL && self->device_list != NULL) {
+               GtkWidget *child;
+
+               g_debug ("Emptying list box as default adapter removed");
+               while ((child = gtk_widget_get_first_child (self->device_list)))
+                       gtk_list_box_remove (GTK_LIST_BOX (self->device_list), child);
+       }
+
        g_object_set (G_OBJECT (client), "default-adapter-setup-mode", default_adapter != NULL, NULL);
 
        g_signal_emit (G_OBJECT (self), signals[ADAPTER_STATUS_CHANGED], 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]