diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-02-11 20:57:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-02-12 10:10:23 +0100 |
commit | 1a490b71feb2340ac4f58ff1bef983ef1115e2f3 (patch) | |
tree | 40632c2beb0f0fd7209bf975505e3b2b3a214f94 /vcl | |
parent | c08ec94ae04656e5178a704445080fe6887aac5a (diff) |
allow using css::graphic::XGraphic to set menu image
Change-Id: Ice5062f26ea300aec73d5fd849484c8bc4fc43bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110793
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salvtables.hxx | 1 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 13 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 9 |
3 files changed, 20 insertions, 3 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index a3941ff51e67..2416aa6ab696 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -153,6 +153,7 @@ public: virtual void clear() override; virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface, + const css::uno::Reference<css::graphic::XGraphic>* pImage, TriState eCheckRadioFalse) override; virtual void insert_separator(int pos, const OUString& rId) override; virtual void remove(const OString& rId) override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index a098a5acf67c..c5fba71e2b1a 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -693,7 +693,9 @@ Image createImage(const VirtualDevice& rDevice) sal_uInt16 insert_to_menu(sal_uInt16 nLastId, PopupMenu* pMenu, int pos, std::u16string_view rId, const OUString& rStr, const OUString* pIconName, - const VirtualDevice* pImageSurface, TriState eCheckRadioFalse) + const VirtualDevice* pImageSurface, + const css::uno::Reference<css::graphic::XGraphic>* pImage, + TriState eCheckRadioFalse) { const sal_uInt16 nNewid = nLastId + 1; @@ -715,6 +717,10 @@ sal_uInt16 insert_to_menu(sal_uInt16 nLastId, PopupMenu* pMenu, int pos, std::u1 { pMenu->SetItemImage(nNewid, createImage(*pImageSurface)); } + else if (pImage) + { + pMenu->SetItemImage(nNewid, Image(*pImage)); + } return nNewid; } } @@ -766,9 +772,10 @@ void SalInstanceMenu::set_visible(const OString& rIdent, bool bShow) void SalInstanceMenu::clear() { m_xMenu->Clear(); } void SalInstanceMenu::insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface, + const css::uno::Reference<css::graphic::XGraphic>* pImage, TriState eCheckRadioFalse) { - m_nLastId = insert_to_menu(m_nLastId, m_xMenu, pos, rId, rStr, pIconName, pImageSurface, + m_nLastId = insert_to_menu(m_nLastId, m_xMenu, pos, rId, rStr, pIconName, pImageSurface, pImage, eCheckRadioFalse); } void SalInstanceMenu::insert_separator(int pos, const OUString& rId) @@ -2663,7 +2670,7 @@ public: TriState eCheckRadioFalse) override { m_nLastId = insert_to_menu(m_nLastId, m_xMenuButton->GetPopupMenu(), pos, rId, rStr, - pIconName, pImageSurface, eCheckRadioFalse); + pIconName, pImageSurface, nullptr, eCheckRadioFalse); } virtual void insert_separator(int pos, const OUString& rId) override diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index d24edef22ae9..2a9e02308cd3 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8282,6 +8282,7 @@ public: virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface, + const css::uno::Reference<css::graphic::XGraphic>* pGraphic, TriState eCheckRadioFalse) override { GtkWidget* pImage = nullptr; @@ -8297,6 +8298,14 @@ public: { pImage = image_new_from_virtual_device(*pImageSurface); } + else if (pGraphic) + { + if (GdkPixbuf* pixbuf = getPixbuf(*pGraphic)) + { + pImage = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); + } + } GtkWidget *pItem; if (pImage) |