[gnome-bluetooth] settings-widget: Replace gtk_dialog_run() by a mainloop
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] settings-widget: Replace gtk_dialog_run() by a mainloop
- Date: Thu, 28 Oct 2021 15:29:59 +0000 (UTC)
commit c25cad5aca09b31b9f60ee43fb6a03b61bfa53b7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Oct 27 14:13:58 2021 -0300
settings-widget: Replace gtk_dialog_run() by a mainloop
gtk_dialog_run() was removed from GTK4, but we can still mimic its behavior
using a custom GMainLoop.
lib/bluetooth-settings-widget.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index b81ea8a3..720bcb9e 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -1312,11 +1312,25 @@ name_changed (BluetoothClient *client,
update_visibility (self);
}
+static void
+confirm_dialog_response_cb (GtkDialog *dialog,
+ gint response,
+ gpointer user_data)
+{
+ GMainLoop *mainloop = g_object_get_data (G_OBJECT (dialog), "mainloop");
+ int *out_response = user_data;
+
+ *out_response = response;
+
+ g_main_loop_quit (mainloop);
+}
+
static gboolean
show_confirm_dialog (BluetoothSettingsWidget *self,
const char *name)
{
BluetoothSettingsWidgetPrivate *priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (self);
+ g_autoptr(GMainLoop) mainloop = NULL;
GtkWidget *dialog;
gint response;
@@ -1330,7 +1344,11 @@ show_confirm_dialog (BluetoothSettingsWidget *self,
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Remove"), GTK_RESPONSE_ACCEPT);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
+ mainloop = g_main_loop_new (NULL, FALSE);
+ g_object_set_data (G_OBJECT (dialog), "mainloop", mainloop);
+ g_signal_connect (dialog, "response", G_CALLBACK (confirm_dialog_response_cb), &response);
+
+ g_main_loop_run (mainloop);
gtk_window_destroy (GTK_WINDOW (dialog));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]