summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-09-14 14:09:18 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2016-09-19 01:56:41 +0300
commit1ef48f3bebe80a386490e2a0f8fd0ae40de07ada (patch)
treefe4831d59172eefe3d4c46dfa2484ed71bf64a9a /vcl
parentee8909ff066bb707c5d1234dc6d609bb5c0251f2 (diff)
GtkSalMenu: Need a way to remove icons too
e.g. user switches menu icons option off. Change-Id: I2a3f2c170f262a4542bfea24eb746f3aa405cbd6
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx31
1 files changed, 18 insertions, 13 deletions
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 604a418032eb..8671f4c387f8 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -250,8 +250,7 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries)
// Force updating of native menu labels.
NativeSetItemText( nSection, nItemPos, aText );
- if (!!aImage)
- NativeSetItemIcon( nSection, nItemPos, aImage );
+ NativeSetItemIcon( nSection, nItemPos, aImage );
NativeSetAccelerator( nSection, nItemPos, nAccelKey, nAccelKey.GetName( GetFrame()->GetWindow() ) );
if ( g_strcmp0( aNativeCommand, "" ) != 0 && pSalMenuItem->mpSubMenu == nullptr )
@@ -870,19 +869,25 @@ void GtkSalMenu::NativeSetItemIcon( unsigned nSection, unsigned nItemPos, const
#if GLIB_CHECK_VERSION(2,38,0)
SolarMutexGuard aGuard;
- SvMemoryStream* pMemStm = new SvMemoryStream;
- vcl::PNGWriter aWriter(rImage.GetBitmapEx());
- aWriter.Write(*pMemStm);
+ if (!!rImage)
+ {
+ SvMemoryStream* pMemStm = new SvMemoryStream;
+ vcl::PNGWriter aWriter(rImage.GetBitmapEx());
+ aWriter.Write(*pMemStm);
+
+ GBytes *pBytes = g_bytes_new_with_free_func(pMemStm->GetData(),
+ pMemStm->Seek(STREAM_SEEK_TO_END),
+ DestroyMemoryStream,
+ pMemStm);
- GBytes *pBytes = g_bytes_new_with_free_func(pMemStm->GetData(),
- pMemStm->Seek(STREAM_SEEK_TO_END),
- DestroyMemoryStream,
- pMemStm);
+ GIcon *pIcon = g_bytes_icon_new(pBytes);
- GIcon *pIcon = g_bytes_icon_new(pBytes);
- g_lo_menu_set_icon_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, pIcon );
- g_object_unref(pIcon);
- g_bytes_unref(pBytes);
+ g_lo_menu_set_icon_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, pIcon );
+ g_object_unref(pIcon);
+ g_bytes_unref(pBytes);
+ }
+ else
+ g_lo_menu_set_icon_to_item_in_section( G_LO_MENU( mpMenuModel ), nSection, nItemPos, nullptr );
#else
(void)nSection;
(void)nItemPos;