[Libreoffice-commits] core.git: include/vcl sfx2/source vcl/inc vcl/source vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 12 09:11:12 UTC 2021
include/vcl/weld.hxx | 11 ++++++-----
sfx2/source/sidebar/SidebarController.cxx | 9 ++++++---
vcl/inc/salvtables.hxx | 1 +
vcl/source/app/salvtables.cxx | 13 ++++++++++---
vcl/unx/gtk3/gtk3gtkinst.cxx | 9 +++++++++
5 files changed, 32 insertions(+), 11 deletions(-)
New commits:
commit 1a490b71feb2340ac4f58ff1bef983ef1115e2f3
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 11 20:57:25 2021 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 12 10:10:23 2021 +0100
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 at redhat.com>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 7921948027a3..c33bd97a098a 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -2220,6 +2220,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>* pImage,
TriState eCheckRadioFalse)
= 0;
@@ -2232,23 +2233,23 @@ public:
void append(const OUString& rId, const OUString& rStr)
{
- insert(-1, rId, rStr, nullptr, nullptr, TRISTATE_INDET);
+ insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_INDET);
}
void append_check(const OUString& rId, const OUString& rStr)
{
- insert(-1, rId, rStr, nullptr, nullptr, TRISTATE_TRUE);
+ insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_TRUE);
}
void append_radio(const OUString& rId, const OUString& rStr)
{
- insert(-1, rId, rStr, nullptr, nullptr, TRISTATE_FALSE);
+ insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_FALSE);
}
void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
{
- insert(-1, rId, rStr, &rImage, nullptr, TRISTATE_INDET);
+ insert(-1, rId, rStr, &rImage, nullptr, nullptr, TRISTATE_INDET);
}
void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
{
- insert(-1, rId, rStr, nullptr, &rImage, TRISTATE_INDET);
+ insert(-1, rId, rStr, nullptr, &rImage, nullptr, TRISTATE_INDET);
}
// return the number of toplevel nodes
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 2af18b6d7558..ae12e361a6ba 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1069,7 +1069,8 @@ void SidebarController::PopulatePopupMenus(weld::Menu& rMenu, weld::Menu& rCusto
for (const auto& rItem : rMenuData)
{
OString sIdent("select" + OString::number(nIndex));
- rMenu.insert(nIndex, OUString::fromUtf8(sIdent), rItem.msDisplayName, nullptr, nullptr, TRISTATE_FALSE);
+ rMenu.insert(nIndex, OUString::fromUtf8(sIdent), rItem.msDisplayName,
+ nullptr, nullptr, nullptr, TRISTATE_FALSE);
rMenu.set_active(sIdent, rItem.mbIsCurrentDeck);
rMenu.set_sensitive(sIdent, rItem.mbIsEnabled && rItem.mbIsActive);
@@ -1079,13 +1080,15 @@ void SidebarController::PopulatePopupMenus(weld::Menu& rMenu, weld::Menu& rCusto
{
// Don't allow the currently visible deck to be disabled.
OString sSubIdent("nocustomize" + OString::number(nIndex));
- rCustomizationMenu.insert(nIndex, OUString::fromUtf8(sSubIdent), rItem.msDisplayName, nullptr, nullptr, TRISTATE_FALSE);
+ rCustomizationMenu.insert(nIndex, OUString::fromUtf8(sSubIdent), rItem.msDisplayName,
+ nullptr, nullptr, nullptr, TRISTATE_FALSE);
rCustomizationMenu.set_active(sSubIdent, true);
}
else
{
OString sSubIdent("customize" + OString::number(nIndex));
- rCustomizationMenu.insert(nIndex, OUString::fromUtf8(sSubIdent), rItem.msDisplayName, nullptr, nullptr, TRISTATE_TRUE);
+ rCustomizationMenu.insert(nIndex, OUString::fromUtf8(sSubIdent), rItem.msDisplayName,
+ nullptr, nullptr, nullptr, TRISTATE_TRUE);
rCustomizationMenu.set_active(sSubIdent, rItem.mbIsEnabled && rItem.mbIsActive);
}
}
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)
More information about the Libreoffice-commits
mailing list