[gnome-bluetooth] lib: Replace gtk_widget_destroy



commit c108682511422d7062a26d6c08490e6eb758845a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Oct 27 12:19:50 2021 -0300

    lib: Replace gtk_widget_destroy
    
    Fortunately for us, all but one of the gtk_widget_destroy() calls can
    be replaced by gtk_window_destroy(). The only exception is the listbox
    row case, but that can be replaced by gtk_list_box_remove().
    
    Replace these gtk_widget_destroy() calls by their appropriate replacement.

 lib/bluetooth-settings-widget.c | 30 +++++++++++++++---------------
 lib/test-client.c               |  2 +-
 lib/test-pairing-dialog.c       |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index 673dcd1e..25e5eb8f 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -245,7 +245,7 @@ setup_pairing_dialog (BluetoothSettingsWidget *self)
        BluetoothSettingsWidgetPrivate *priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (self);
        GtkWidget *toplevel;
 
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
        priv->pairing_dialog = bluetooth_pairing_dialog_new ();
        toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
        gtk_window_set_transient_for (GTK_WINDOW (priv->pairing_dialog), GTK_WINDOW (toplevel));
@@ -343,7 +343,7 @@ display_cb (GtkDialog *dialog,
 {
        BluetoothSettingsWidgetPrivate *priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (user_data);
 
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 }
 
 static void
@@ -368,7 +368,7 @@ enter_pin_cb (GtkDialog *dialog,
                                                       g_variant_new ("(s)", pin));
 
                if (bluetooth_pairing_dialog_get_mode (BLUETOOTH_PAIRING_DIALOG (priv->pairing_dialog)) == 
BLUETOOTH_PAIRING_MODE_PIN_QUERY) {
-                       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+                       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
                        return;
                }
                bluetooth_pairing_dialog_set_mode (BLUETOOTH_PAIRING_DIALOG (priv->pairing_dialog),
@@ -379,7 +379,7 @@ enter_pin_cb (GtkDialog *dialog,
                g_dbus_method_invocation_return_dbus_error (invocation,
                                                            "org.bluez.Error.Canceled",
                                                            "User cancelled pairing");
-               g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+               g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
                return;
        }
 
@@ -413,7 +413,7 @@ confirm_remote_pin_cb (GtkDialog *dialog,
                g_dbus_method_invocation_return_dbus_error (invocation, "org.bluez.Error.Rejected", "Pairing 
refused from settings panel");
        }
 
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 }
 
 static void
@@ -549,7 +549,7 @@ display_passkey_or_pincode_cb (GtkDialog *dialog,
                g_assert_not_reached ();
        }
 
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 }
 
 static void
@@ -674,7 +674,7 @@ cancel_callback (GDBusMethodInvocation *invocation,
 
        g_debug ("cancel_callback ()");
 
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 
        children = gtk_container_get_children (GTK_CONTAINER (priv->device_list));
        for (l = children; l != NULL; l = l->next)
@@ -702,7 +702,7 @@ confirm_cb (GtkDialog *dialog,
                                                            "org.bluez.Error.Canceled",
                                                            "User cancelled pairing");
        }
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 }
 
 static void
@@ -779,7 +779,7 @@ authorize_service_cb (GtkDialog *dialog,
                msg = g_strdup_printf ("Rejecting service auth (HID): not paired or trusted");
                g_dbus_method_invocation_return_dbus_error (invocation, "org.bluez.Error.Rejected", msg);
        }
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 }
 
 static void
@@ -950,7 +950,7 @@ create_callback (GObject      *source_object,
 
                priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (user_data);
 
-               g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+               g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 
                turn_off_pairing (user_data, path);
 
@@ -981,7 +981,7 @@ create_callback (GObject      *source_object,
 
        priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (user_data);
 
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
 
        g_hash_table_remove (priv->pairing_devices, path);
 
@@ -1328,7 +1328,7 @@ show_confirm_dialog (BluetoothSettingsWidget *self,
 
        response = gtk_dialog_run (GTK_DIALOG (dialog));
 
-       gtk_widget_destroy (dialog);
+       gtk_window_destroy (GTK_WINDOW (dialog));
 
        if (response == GTK_RESPONSE_ACCEPT)
                return TRUE;
@@ -1777,7 +1777,7 @@ device_removed_cb (BluetoothClient *client,
                        g_object_get (G_OBJECT (l->data), "name", &name, NULL);
                        g_debug ("Removing device '%s'", name ? name : object_path);
 
-                       gtk_widget_destroy (GTK_WIDGET (l->data));
+                       gtk_list_box_remove (GTK_LIST_BOX (priv->device_list), GTK_WIDGET (l->data));
                        found = TRUE;
                        break;
                }
@@ -1999,8 +1999,8 @@ bluetooth_settings_widget_finalize (GObject *object)
        BluetoothSettingsWidgetPrivate *priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (widget);
 
        g_clear_object (&priv->agent);
-       g_clear_pointer (&priv->properties_dialog, gtk_widget_destroy);
-       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->properties_dialog, gtk_window_destroy);
+       g_clear_pointer ((GtkWindow**)&priv->pairing_dialog, gtk_window_destroy);
        g_clear_object (&priv->session_proxy);
 
        obex_agent_down ();
diff --git a/lib/test-client.c b/lib/test-client.c
index b2f20464..e077f24a 100644
--- a/lib/test-client.c
+++ b/lib/test-client.c
@@ -38,7 +38,7 @@ static GtkTreeSelection *selection;
 static void delete_callback(GtkWidget *window, GdkEvent *event,
                                                gpointer user_data)
 {
-       gtk_widget_destroy(window);
+       gtk_window_destroy(GTK_WINDOW(window));
 
        gtk_main_quit();
 }
diff --git a/lib/test-pairing-dialog.c b/lib/test-pairing-dialog.c
index e2909fcf..6745bb72 100644
--- a/lib/test-pairing-dialog.c
+++ b/lib/test-pairing-dialog.c
@@ -27,7 +27,7 @@ response_cb (GtkDialog *dialog,
        if (response == GTK_RESPONSE_CANCEL ||
            response == GTK_RESPONSE_DELETE_EVENT) {
                if (response != GTK_RESPONSE_DELETE_EVENT)
-                       gtk_widget_destroy (GTK_WIDGET (dialog));
+                       gtk_window_destroy (GTK_WINDOW (dialog));
                gtk_main_quit ();
                return;
        }
@@ -38,7 +38,7 @@ response_cb (GtkDialog *dialog,
                                                   "234567",
                                                   "My device");
        } else {
-               gtk_widget_destroy (GTK_WIDGET (dialog));
+               gtk_window_destroy (GTK_WINDOW (dialog));
                gtk_main_quit ();
        }
 }


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