[balsa/popover] balsa-index, balsa-message: Clean up popup code



commit 77ad60c51fe368299b970c9f3ebf1ab5340060e6
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu May 14 13:06:02 2020 -0400

    balsa-index, balsa-message: Clean up popup code

 src/balsa-index.c   | 6 +-----
 src/balsa-message.c | 4 +++-
 2 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 82a98cd85..1f83da40f 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -240,11 +240,6 @@ bndx_destroy(GObject * obj)
         bindex->search_iter = NULL;
     }
 
-    if (bindex->popup_menu) {
-        g_object_unref(bindex->popup_menu);
-        bindex->popup_menu = NULL;
-    }
-
     if (bindex->selection_changed_idle_id != 0) {
         g_source_remove(bindex->selection_changed_idle_id);
         bindex->selection_changed_idle_id = 0;
@@ -2082,6 +2077,7 @@ bndx_do_popup(BalsaIndex * index, GdkEventButton * event)
     /* Replace the existing submenu */
     g_menu_remove(index->popup_menu, index->move_position);
     g_menu_insert_item(index->popup_menu, index->move_position, item);
+    g_object_unref(item);
 
     gtk_widget_get_allocation(GTK_WIDGET(index), &allocation);
     if (event != NULL && gdk_event_triggers_context_menu((GdkEvent *) event)) {
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 45ef5b336..ab906415f 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1711,8 +1711,10 @@ display_content(BalsaMessage * balsa_message)
 
     balsa_message->parts_menu = g_menu_new();
 
+    /* Detach any existing popup: */
     if (balsa_message->parts_popup != NULL)
-       g_object_unref(balsa_message->parts_popup);
+       gtk_popover_set_relative_to(GTK_POPOVER(balsa_message->parts_popup), NULL);
+
     balsa_message->parts_popup =
         gtk_popover_new_from_model(balsa_message->attach_button,
                                    G_MENU_MODEL(balsa_message->parts_menu));


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