summaryrefslogtreecommitdiff
path: root/lib/test-pairing-dialog.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-12-02 19:09:26 +0100
committerBastien Nocera <hadess@hadess.net>2013-12-06 12:00:30 +0100
commit4b2c4fd253bc49d2aad7a44013a9ca3b8131e81e (patch)
tree80d08d8663d135ad6a454bbcaccde52577a5bc85 /lib/test-pairing-dialog.c
parentef7d54646d44d6c8d7a12dda587564d84cd1aa32 (diff)
downloadgnome-bluetooth-4b2c4fd253bc49d2aad7a44013a9ca3b8131e81e.tar.gz
lib: Add Settings widget
Rather than implementing the majority of the settings widget inside the control-center, implement it within gnome-bluetooth so we can cut down on the necessary amount of exported symbols and functions. And remove the stand-alone wizard as it duplicated functionality. https://bugzilla.gnome.org/show_bug.cgi?id=719564
Diffstat (limited to 'lib/test-pairing-dialog.c')
-rw-r--r--lib/test-pairing-dialog.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/test-pairing-dialog.c b/lib/test-pairing-dialog.c
new file mode 100644
index 00000000..1cc567fa
--- /dev/null
+++ b/lib/test-pairing-dialog.c
@@ -0,0 +1,65 @@
+#include "bluetooth-pairing-dialog.h"
+
+static const char *
+response_to_str (int response)
+{
+ switch (response) {
+ case GTK_RESPONSE_ACCEPT:
+ return "accept";
+ case GTK_RESPONSE_CANCEL:
+ return "cancel";
+ case GTK_RESPONSE_DELETE_EVENT:
+ return "delete-event";
+ default:
+ g_message ("response %d unhandled", response);
+ g_assert_not_reached ();
+ }
+}
+
+static void
+response_cb (GtkDialog *dialog,
+ int response,
+ gpointer user_data)
+{
+ g_message ("Received response '%d' (%s)",
+ response, response_to_str (response));
+
+ if (response == GTK_RESPONSE_CANCEL ||
+ response == GTK_RESPONSE_DELETE_EVENT) {
+ if (response != GTK_RESPONSE_DELETE_EVENT)
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_main_quit ();
+ return;
+ }
+
+ if (bluetooth_pairing_dialog_get_mode (BLUETOOTH_PAIRING_DIALOG (user_data)) == BLUETOOTH_PAIRING_MODE_PIN_CONFIRMATION) {
+ bluetooth_pairing_dialog_set_mode (BLUETOOTH_PAIRING_DIALOG (user_data),
+ BLUETOOTH_PAIRING_MODE_PIN_DISPLAY_NORMAL,
+ "234567",
+ "My device");
+ } else {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_main_quit ();
+ }
+}
+
+int main (int argc, char **argv)
+{
+ GtkWidget *window;
+
+ gtk_init (&argc, &argv);
+
+ window = bluetooth_pairing_dialog_new ();
+ bluetooth_pairing_dialog_set_mode (BLUETOOTH_PAIRING_DIALOG (window),
+ BLUETOOTH_PAIRING_MODE_YES_NO,
+ NULL,
+ "My device");
+ g_signal_connect (G_OBJECT (window), "response",
+ G_CALLBACK (response_cb), window);
+
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}