[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 7 11:20:44 UTC 2021
vcl/unx/gtk3/gtkinst.cxx | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
New commits:
commit bcd39bc1e36c06ce1221a9d981363c292b614938
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jul 7 11:08:28 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 7 13:20:10 2021 +0200
gtk4: implement set_item_label for GMenuModel
Change-Id: Iee721fa9f50b2884b2d0e726c36d6821e135a561
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118555
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 8495612b3c82..535644fb528f 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -9664,7 +9664,10 @@ public:
GMenuItem* pMenuItem = g_menu_item_new_from_model(pSectionModel, i);
g_menu_prepend_item(pNewSection, pMenuItem);
g_menu_remove(G_MENU(pSectionModel), i);
+ g_object_unref(pMenuItem);
}
+ g_object_unref(pSectionItem);
+ g_object_unref(pNewSection);
}
}
}
@@ -9734,8 +9737,22 @@ public:
MenuHelper::set_item_label(rIdent, rLabel);
#else
- (void)rIdent; (void)rLabel;
- std::abort();
+ 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)
+ {
+ std::pair<GMenuModel*, int> aRes = find_id(pMenuModel, rIdent);
+ if (!aRes.first)
+ return;
+ // clone the original item, remove the original, insert the replacement at
+ // the original location
+ GMenuItem* pMenuItem = g_menu_item_new_from_model(aRes.first, aRes.second);
+ g_menu_remove(G_MENU(aRes.first), aRes.second);
+ g_menu_item_set_label(pMenuItem, MapToGtkAccelerator(rLabel).getStr());
+ g_menu_insert_item(G_MENU(aRes.first), aRes.second, pMenuItem);
+ g_object_unref(pMenuItem);
+ }
#endif
}
More information about the Libreoffice-commits
mailing list