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




commit bdae2acf3c6d7395f8f279501d3ee8f471719ed7
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.

 lib/bluetooth-settings-widget.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index 15c5489c..546bd5ef 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -541,6 +541,24 @@ display_callback (GDBusMethodInvocation *invocation,
        gtk_widget_show (priv->pairing_dialog);
 }
 
+static void
+display_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_pincode_callback (GDBusMethodInvocation *invocation,
                          GDBusProxy            *device,
@@ -598,6 +616,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_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]