[balsa/gtk4: 41/289] Various: Make GtkMenu versions work




commit bde0ae586c4786064958ad0f038bb47509aa9233
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jun 15 11:51:16 2020 -0400

    Various: Make GtkMenu versions work
    
    Each menu needs to be attached to a widget, which both handles destruction
    and gives access to the necessary action group.
    
    Fixes the issue noted in b752ed667697a38f1b4edf5650c7132fd2e5d25e
    
    * src/balsa-index.c (bndx_popup_menu_create):
    * src/balsa-message.c (balsa_message_init), (display_content), (part_create_menu):
    * src/balsa-mime-widget-text.c (bmwt_html_popup_context_menu):
    * src/mailbox-node.c (create_context_menu):
    * src/sendmsg-window.c (add_attachment), (add_urlref_attachment):
    * src/toolbar-factory.c (tm_popup_context_menu_cb):

 ChangeLog                    | 15 +++++++++++++++
 src/balsa-index.c            |  1 +
 src/balsa-message.c          | 11 +++++++----
 src/balsa-mime-widget-text.c |  3 +++
 src/mailbox-node.c           |  6 ++++--
 src/sendmsg-window.c         |  3 ++-
 src/toolbar-factory.c        |  1 +
 7 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 956c1030e..09feb66da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -252,6 +252,21 @@
 
        * src/main.c (balsa_startup_cb):
 
+2020-06-15  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Various: Make GtkMenu versions work.
+
+       Each menu needs to be attached to a widget, which both handles
+       destruction and gives access to the necessary action group.
+
+       * src/balsa-index.c (bndx_popup_menu_create):
+       * src/balsa-message.c (balsa_message_init), (display_content),
+       (part_create_menu):
+       * src/balsa-mime-widget-text.c (bmwt_html_popup_context_menu):
+       * src/mailbox-node.c (create_context_menu):
+       * src/sendmsg-window.c (add_attachment), (add_urlref_attachment):
+       * src/toolbar-factory.c (tm_popup_context_menu_cb):
+
 2020-06-15  Peter Bloomfield  <pbloomfield bellsouth net>
 
        pref-manager: Use GtkMenuButton to pop-up "Add" menus
diff --git a/src/balsa-index.c b/src/balsa-index.c
index ba91c6341..425b43c1b 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -2140,6 +2140,7 @@ bndx_popup_menu_create(BalsaIndex * bindex)
         gtk_popover_set_position(GTK_POPOVER(bindex->popup_widget), GTK_POS_BOTTOM);
     } else {
         bindex->popup_widget = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+        gtk_menu_attach_to_widget(GTK_MENU(bindex->popup_widget), GTK_WIDGET(bindex), NULL);
     }
 }
 
diff --git a/src/balsa-message.c b/src/balsa-message.c
index b84e41567..1b8b505f0 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1006,6 +1006,9 @@ balsa_message_init(BalsaMessage * balsa_message)
             gtk_popover_new_from_model(balsa_message->treeview, G_MENU_MODEL(menu));
     } else {
         balsa_message->save_all_popup = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+        gtk_menu_attach_to_widget(GTK_MENU(balsa_message->save_all_popup),
+                                  balsa_message->treeview,
+                                  NULL);
     }
     g_object_unref(menu);
 
@@ -1790,12 +1793,11 @@ display_content(BalsaMessage * balsa_message)
             gtk_popover_new_from_model(balsa_message->attach_button,
                                        G_MENU_MODEL(balsa_message->parts_menu));
     } else {
-        if (balsa_message->parts_popup)
-            g_object_unref(balsa_message->parts_popup);
-
         balsa_message->parts_popup =
             gtk_menu_new_from_model(G_MENU_MODEL(balsa_message->parts_menu));
-        g_object_ref_sink(balsa_message->parts_popup);
+        gtk_menu_attach_to_widget(GTK_MENU(balsa_message->parts_popup),
+                                  balsa_message->attach_button,
+                                  NULL);
     }
 
     /* Populate the parts-menu */
@@ -1948,6 +1950,7 @@ part_create_menu(BalsaMessage *balsa_message, BalsaPartInfo *info)
             gtk_popover_new_from_model(balsa_message->treeview, G_MENU_MODEL(menu));
     } else {
         info->popup_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+        gtk_menu_attach_to_widget(GTK_MENU(info->popup_menu), balsa_message->treeview, NULL);
     }
 
     g_object_unref(menu);
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index e503474a0..b04eebd31 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1299,6 +1299,9 @@ bmwt_html_popup_context_menu(GtkWidget    *html,
                                                     G_MENU_MODEL(menu));
         } else {
             popup_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+            gtk_menu_attach_to_widget(GTK_MENU(popup_menu),
+                                      libbalsa_html_get_view_widget(html),
+                                      NULL);
         }
 
         g_object_set_data(G_OBJECT(html), "popup-menu", popup_menu);
diff --git a/src/mailbox-node.c b/src/mailbox-node.c
index 7add81023..ac86be1de 100644
--- a/src/mailbox-node.c
+++ b/src/mailbox-node.c
@@ -1187,10 +1187,12 @@ create_context_menu(BalsaMailboxNode *mbnode,
     g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
     g_object_unref(section);
 
-    if (libbalsa_use_popover())
+    if (libbalsa_use_popover()) {
         context_menu = gtk_popover_new_from_model(relative_to, G_MENU_MODEL(menu));
-    else
+    } else {
         context_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+        gtk_menu_attach_to_widget(GTK_MENU(context_menu), relative_to, NULL);
+    }
     g_object_unref(menu);
 
     return context_menu;
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 412515fb4..011c90a1b 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1812,6 +1812,7 @@ add_attachment(BalsaSendmsg * bsmsg, const gchar *filename,
                                   G_MENU_MODEL(menu),
                                   attachment_namespace,
                                   TRUE);
+        gtk_menu_attach_to_widget(GTK_MENU(attach_data->popup_menu), bsmsg->tree_view, NULL);
     }
 
     g_object_unref(menu);
@@ -1903,7 +1904,7 @@ add_urlref_attachment(BalsaSendmsg * bsmsg, const gchar *url)
             gtk_popover_new_from_model(bsmsg->window, G_MENU_MODEL(menu));
     } else {
         attach_data->popup_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
-        gtk_widget_show_all(attach_data->popup_menu);
+        gtk_menu_attach_to_widget(GTK_MENU(attach_data->popup_menu), bsmsg->window, NULL);
     }
     g_object_unref(menu);
 
diff --git a/src/toolbar-factory.c b/src/toolbar-factory.c
index b8b5fd647..b4a442ad3 100644
--- a/src/toolbar-factory.c
+++ b/src/toolbar-factory.c
@@ -733,6 +733,7 @@ tm_popup_context_menu_cb(GtkWidget    * toolbar,
     } else {
         popup_menu = gtk_menu_new();
         gtk_menu_shell_bind_model(GTK_MENU_SHELL(popup_menu), G_MENU_MODEL(menu), namespace, TRUE);
+        gtk_menu_attach_to_widget(GTK_MENU(popup_menu), toolbar, NULL);
     }
 
     g_object_unref(menu);


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