[balsa/gtk4: 169/196] autocrypt: Stop using gtk_dialog_run()




commit be4a36a09995d589c1401acbecb9d891553508e4
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu Oct 1 12:02:06 2020 -0400

    autocrypt: Stop using gtk_dialog_run()
    
    Use the "response" signal handler to destroy the dialog, and free any
    memory.

 libbalsa/autocrypt.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/libbalsa/autocrypt.c b/libbalsa/autocrypt.c
index 247d77ee1..50d85440d 100644
--- a/libbalsa/autocrypt.c
+++ b/libbalsa/autocrypt.c
@@ -415,6 +415,16 @@ autocrypt_recommendation(InternetAddressList *recipients, GList **missing_keys,
        return result;
 }
 
+static void
+main_dialog_response_cb(GtkDialog *dialog,
+                        int        response_id,
+                        gpointer   user_data)
+{
+    GList *keys = user_data;
+
+    g_list_free_full(keys, (GDestroyNotify) g_bytes_unref);
+    gtk_widget_destroy(GTK_WIDGET(dialog));
+}
 
 /* documentation: see header file */
 void
@@ -518,9 +528,8 @@ autocrypt_db_dialog_run(const gchar *date_string, GtkWindow *parent)
        gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
        gtk_tree_view_column_set_resizable(column, TRUE);
 
-        g_signal_connect(dialog, "response", G_CALLBACK(gtk_window_destroy), NULL);
-       gtk_widget_show(dialog);
-       g_list_free_full(keys, (GDestroyNotify) g_bytes_unref);
+        g_signal_connect(dialog, "response", G_CALLBACK(main_dialog_response_cb), keys);
+        gtk_widget_show(dialog);
 }
 
 
@@ -773,7 +782,6 @@ update_last_seen(GMimeAutocryptHeader *autocrypt_header, GError **error)
        sqlite3_reset(query[3]);
 }
 
-
 static void
 row_activated_cb(GtkTreeView       *tree_view,
                  GtkTreePath       *path,
@@ -807,9 +815,9 @@ row_activated_cb(GtkTreeView       *tree_view,
 
                                dialog = libbalsa_key_dialog(window, GTK_BUTTONS_CLOSE, (gpgme_key_t) 
keys->data, GPG_SUBKEY_CAP_ALL,
                                        NULL, NULL);
-                                g_signal_connect(dialog, "response", G_CALLBACK(gtk_window_destroy), NULL);
-                               gtk_widget_show(dialog);
-                               g_list_free_full(keys, (GDestroyNotify) gpgme_key_release);
+                                g_list_free_full(keys, (GDestroyNotify) gpgme_key_release);
+                                g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
+                                gtk_widget_show(dialog);
                                }
                                libbalsa_delete_directory_contents(temp_dir);
                                g_rmdir(temp_dir);


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