[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 7 16:37:56 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |   29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

New commits:
commit e3c1460462ce1fdb7073b876c1d802e4b2cb49c6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jul 7 16:21:37 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 7 18:37:20 2021 +0200

    gtk4: implement MenuHelper::clear_items for gtk4
    
    Change-Id: I0df18e50ad8955b3e5933287cba2ddcee02fec31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118577
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index c35af7b23d96..79cabe5f3ec0 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -5282,6 +5282,15 @@ public:
             gtk_widget_destroy(GTK_WIDGET(pMenuItem));
         }
         m_aMap.clear();
+#else
+        if (GMenuModel* pMenuModel = gtk_popover_menu_get_menu_model(m_pMenu))
+        {
+            GMenu* pMenu = G_MENU(pMenuModel);
+            g_menu_remove_all(pMenu);
+            g_menu_insert_section(pMenu, 0, nullptr, G_MENU_MODEL(g_menu_new()));
+            m_aHiddenIds.clear();
+            update_action_group_from_popover_model();
+        }
 #endif
     }
 
@@ -9805,21 +9814,7 @@ public:
 
     virtual void clear() override
     {
-#if GTK_CHECK_VERSION(4, 0, 0)
-        GtkPopover* pPopover = gtk_menu_button_get_popover(m_pMenuButton);
-        if (GMenuModel* pMenuModel = GTK_IS_POPOVER_MENU(pPopover) ?
-                                     gtk_popover_menu_get_menu_model(GTK_POPOVER_MENU(pPopover)) :
-                                     nullptr)
-        {
-            GMenu* pMenu = G_MENU(pMenuModel);
-            g_menu_remove_all(pMenu);
-            g_menu_insert_section(pMenu, 0, nullptr, G_MENU_MODEL(g_menu_new()));
-            m_aHiddenIds.clear();
-            update_action_group_from_popover_model();
-        }
-#else
-        clear_items();
-#endif
+        MenuHelper::clear_items();
     }
 
     virtual void set_item_active(const OString& rIdent, bool bActive) override
@@ -10183,7 +10178,7 @@ public:
 
     virtual void clear() override
     {
-        clear_items();
+        MenuHelper::clear_items();
     }
 
     virtual void set_item_active(const OString& rIdent, bool bActive) override
@@ -10442,8 +10437,8 @@ public:
     {
 #if !GTK_CHECK_VERSION(4, 0, 0)
         clear_extras();
-        clear_items();
 #endif
+        MenuHelper::clear_items();
     }
 
     virtual void insert(int pos, const OUString& rId, const OUString& rStr,


More information about the Libreoffice-commits mailing list