[gnome-bluetooth/wip/hadess/fix-keyboard-cancel: 1/2] settings-widget: Make the "Cancel" button work when pairing keyboards




commit 99e78f4319a0691d81e0758b2e33801f1a9fa3aa
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Feb 18 16:54:49 2021 +0100

    settings-widget: Make the "Cancel" button work when pairing keyboards
    
    Connect to the dialogue's "response" signal so that the dialogue is
    closed when "Cancel" gets clicked.
    
    Closes: #52

 lib/bluetooth-settings-widget.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index 9b980a70..4273b202 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -511,6 +511,24 @@ pincode_callback (GDBusMethodInvocation *invocation,
        gtk_widget_show (priv->pairing_dialog);
 }
 
+static void
+display_passkey_or_pincode_cb (GtkDialog *dialog,
+                              int        response,
+                              gpointer   user_data)
+{
+       BluetoothSettingsWidgetPrivate *priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (user_data);
+
+       if (response == GTK_RESPONSE_CANCEL ||
+           response == GTK_RESPONSE_DELETE_EVENT) {
+               //FIXME
+               //Run CancelPairing()
+       } else {
+               g_assert_not_reached ();
+       }
+
+       g_clear_pointer (&priv->pairing_dialog, gtk_widget_destroy);
+}
+
 static void
 display_passkey_callback (GDBusMethodInvocation *invocation,
                          GDBusProxy            *device,
@@ -537,6 +555,8 @@ display_passkey_callback (GDBusMethodInvocation *invocation,
                                           name);
        bluetooth_pairing_dialog_set_pin_entered (BLUETOOTH_PAIRING_DIALOG (priv->pairing_dialog),
                                                  entered);
+       g_signal_connect (G_OBJECT (priv->pairing_dialog), "response",
+                         G_CALLBACK (display_passkey_or_pincode_cb), user_data);
 
        gtk_widget_show (priv->pairing_dialog);
 }
@@ -598,6 +618,8 @@ display_pincode_callback (GDBusMethodInvocation *invocation,
                                           BLUETOOTH_PAIRING_MODE_PIN_DISPLAY_KEYBOARD,
                                           display_pin,
                                           name);
+       g_signal_connect (G_OBJECT (priv->pairing_dialog), "response",
+                         G_CALLBACK (display_passkey_or_pincode_cb), user_data);
        gtk_widget_show (priv->pairing_dialog);
 
        g_dbus_method_invocation_return_value (invocation, NULL);


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