diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-11-14 20:01:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-11-15 20:09:24 +0100 |
commit | 8a92373a20dfce8112e45bd80f0f6c927224ff98 (patch) | |
tree | 11505e7ef2f9faf711ee4f73cc3179fb3ab122a7 | |
parent | 07caaab2e49d5fb409810025867b5ada6968c7e2 (diff) |
add Menu::get_id
Change-Id: I608db63f700312f7d7ffc6bfbd0e03971bfb00e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105845
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/vcl/weld.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/salvtables.hxx | 1 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 10 |
4 files changed, 17 insertions, 0 deletions
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 7387db806350..28dd95818293 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -2174,6 +2174,8 @@ public: // return the number of toplevel nodes virtual int n_children() const = 0; + virtual OString get_id(int pos) const = 0; + virtual ~Menu() {} }; diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 7eff04d56c7e..f3f4a585cecf 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -151,6 +151,7 @@ public: TriState eCheckRadioFalse) override; virtual void insert_separator(int pos, const OUString& rId) override; virtual void remove(const OString& rId) override; + virtual OString get_id(int pos) const override; virtual int n_children() const override; PopupMenu* getMenu() const; virtual ~SalInstanceMenu() override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 585dd36325a3..82e742c62da9 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -763,6 +763,10 @@ void SalInstanceMenu::remove(const OString& rId) m_xMenu->RemoveItem(m_xMenu->GetItemPos(m_xMenu->GetItemId(rId))); } int SalInstanceMenu::n_children() const { return m_xMenu->GetItemCount(); } +OString SalInstanceMenu::get_id(int pos) const +{ + return m_xMenu->GetItemIdent(m_xMenu->GetItemId(pos)); +} PopupMenu* SalInstanceMenu::getMenu() const { return m_xMenu.get(); } SalInstanceMenu::~SalInstanceMenu() { diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index a74533faa787..1b53f714a6ec 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8156,6 +8156,16 @@ public: gtk_menu_reorder_child(m_pMenu, pItem, pos); } + virtual OString get_id(int pos) const override + { + GList* pChildren = gtk_container_get_children(GTK_CONTAINER(m_pMenu)); + gpointer pMenuItem = g_list_nth_data(pChildren, pos); + const gchar* pStr = gtk_buildable_get_name(GTK_BUILDABLE(pMenuItem)); + OString id(pStr, pStr ? strlen(pStr) : 0); + g_list_free(pChildren); + return id; + } + virtual int n_children() const override { GList* pChildren = gtk_container_get_children(GTK_CONTAINER(m_pMenu)); |