summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-07-07 16:03:04 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-07-07 17:57:32 +0200
commitc118d90e13fff1b9404e179b61cd5919115a449c (patch)
treeda0084cc3d55fc3b8b16ae0f67b95b612e034089
parent857943a0e4e75f12ffe7b1dc9d91ef88fbdb75d6 (diff)
gtk4: add get_item_id to MenuHelper
and implement for the GMenuModel case Change-Id: I57da4d984f6a743043cd82c32edff35115fe94c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118575 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx34
1 files changed, 25 insertions, 9 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index cd4f8efc8e40..da39cf03f41a 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -5248,6 +5248,30 @@ public:
#endif
}
+ OString get_item_id(int pos) const
+ {
+#if !GTK_CHECK_VERSION(4, 0, 0)
+ GList* pChildren = gtk_container_get_children(GTK_CONTAINER(m_pMenu));
+ gpointer pMenuItem = g_list_nth_data(pChildren, pos);
+ OString id = ::get_buildable_id(GTK_BUILDABLE(pMenuItem));
+ g_list_free(pChildren);
+ return id;
+#else
+ OString sTarget;
+ if (GMenuModel* pMenuModel = gtk_popover_menu_get_menu_model(m_pMenu))
+ {
+ auto aSectionAndPos = get_section_and_pos_for(pMenuModel, pos);
+ char *id;
+ if (g_menu_model_get_item_attribute(aSectionAndPos.first, aSectionAndPos.second, "target", "s", &id))
+ {
+ sTarget = OString(id);
+ g_free(id);
+ }
+ }
+ return sTarget;
+#endif
+ }
+
void clear_items()
{
#if !GTK_CHECK_VERSION(4, 0, 0)
@@ -10486,15 +10510,7 @@ public:
virtual OString get_id(int pos) const override
{
-#if !GTK_CHECK_VERSION(4, 0, 0)
- GList* pChildren = gtk_container_get_children(GTK_CONTAINER(m_pMenu));
- gpointer pMenuItem = g_list_nth_data(pChildren, pos);
- OString id = ::get_buildable_id(GTK_BUILDABLE(pMenuItem));
- g_list_free(pChildren);
- return id;
-#else
- return OString();
-#endif
+ return get_item_id(pos);
}
virtual int n_children() const override