diff options
author | Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at> | 2015-10-26 13:41:32 +0100 |
---|---|---|
committer | Björn Michaelsen <bjoern.michaelsen@canonical.com> | 2015-10-26 13:23:37 +0000 |
commit | ac5b2047ca72677d6beaf58ddaa8fdcda7236292 (patch) | |
tree | 999f2ff299b3b73ef7f157ccc5109700dc7d8f49 /vcl | |
parent | 5b4c29b1b15dcebfe4e76aaa8bdb2dd45e2b67f3 (diff) |
Let Gtk handle icon names instead of ResMgr for window and trayicon
The icons in the themes should be deleted in a second step and the defines
should be transformed into an ENUM and stored in one place.
Furthermore we will have to decide whether to live with gtkimagemenuitem
despite its deprecation in Gtk3.10 or whether to pack GtkImages and
GtkLabels in GtkBoxes inside GtkMenuItems and live with the additional
padding, which potentially looks horrible.
Change-Id: I8dec44375e40a4d2b6668792bc4b813efe83ff31
Reviewed-on: https://gerrit.libreoffice.org/19601
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/svids.hrc | 3 | ||||
-rw-r--r-- | vcl/source/src/images.src | 120 | ||||
-rw-r--r-- | vcl/unx/gtk/window/gtksalframe.cxx | 146 |
3 files changed, 17 insertions, 252 deletions
diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc index f427b20dce0a..62e32033d41c 100644 --- a/vcl/inc/svids.hrc +++ b/vcl/inc/svids.hrc @@ -181,9 +181,6 @@ #define SV_ICON_SIZE32_START 21000 #define SV_ICON_SIZE16_START 23000 -#define SV_ICON_LARGE_START 24000 -#define SV_ICON_SMALL_START 25000 - #define SV_ICON_ID_OFFICE 1 #define SV_ICON_ID_TEXT 2 #define SV_ICON_ID_TEXT_TEMPLATE 3 diff --git a/vcl/source/src/images.src b/vcl/source/src/images.src index 8ab82c289771..88d35c14824f 100644 --- a/vcl/source/src/images.src +++ b/vcl/source/src/images.src @@ -274,126 +274,6 @@ Bitmap (SV_ICON_SIZE16_START + SV_ICON_ID_TEMPLATE) File = "mainapp_16_8.png" ; }; -Bitmap (SV_ICON_LARGE_START) -{ - File = "mainapp_32.png" ; -}; - -Bitmap (SV_ICON_SMALL_START) -{ - File = "mainapp_16.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_OFFICE) -{ - File = "mainapp_32.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_OFFICE) -{ - File = "mainapp_16.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_TEXT) -{ - File = "lx03251.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_TEXT) -{ - File = "sx03251.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_TEXT_TEMPLATE) -{ - File = "lx03255.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_TEXT_TEMPLATE) -{ - File = "sx03255.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_SPREADSHEET) -{ - File = "lx03250.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_SPREADSHEET) -{ - File = "sx03250.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_SPREADSHEET_TEMPLATE) -{ - File = "lx03254.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_SPREADSHEET_TEMPLATE) -{ - File = "sx03254.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_DRAWING) -{ - File = "lx03246.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_DRAWING) -{ - File = "sx03246.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_PRESENTATION) -{ - File = "lx03249.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_PRESENTATION) -{ - File = "sx03249.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_MASTER_DOCUMENT) -{ - File = "lx03248.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_MASTER_DOCUMENT) -{ - File = "sx03248.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_DATABASE) -{ - File = "lx03245.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_DATABASE) -{ - File = "sx03245.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_FORMULA) -{ - File = "lx03247.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_FORMULA) -{ - File = "sx03247.png" ; -}; - -Bitmap (SV_ICON_LARGE_START + SV_ICON_ID_TEMPLATE) -{ - File = "lx03242.png" ; -}; - -Bitmap (SV_ICON_SMALL_START + SV_ICON_ID_TEMPLATE) -{ - File = "sx03242.png" ; -}; - Bitmap SV_DISCLOSURE_PLUS { File = "plus.png"; diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index e2d5507af2b1..fa6a31b7e401 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -56,7 +56,6 @@ #include <dlfcn.h> #include <vcl/salbtype.hxx> -#include <vcl/bitmapex.hxx> #include <impbmp.hxx> #include <svids.hrc> #include <sal/macros.h> @@ -1655,141 +1654,30 @@ getRow( BitmapBuffer *pBuffer, sal_uLong nRow ) return pBuffer->mpBits + ( pBuffer->mnHeight - nRow - 1 ) * pBuffer->mnScanlineSize; } -static GdkPixbuf * -bitmapToPixbuf( SalBitmap *pSalBitmap, SalBitmap *pSalAlpha ) -{ - g_return_val_if_fail( pSalBitmap != NULL, NULL ); - g_return_val_if_fail( pSalAlpha != NULL, NULL ); - - BitmapBuffer *pBitmap = pSalBitmap->AcquireBuffer( BITMAP_READ_ACCESS ); - g_return_val_if_fail( pBitmap != NULL, NULL ); - g_return_val_if_fail( pBitmap->mnBitCount == 24 || pBitmap->mnBitCount == 32, NULL ); - - BitmapBuffer *pAlpha = pSalAlpha->AcquireBuffer( BITMAP_READ_ACCESS ); - g_return_val_if_fail( pAlpha != NULL, NULL ); - g_return_val_if_fail( pAlpha->mnBitCount == 8, NULL ); - - Size aSize = pSalBitmap->GetSize(); - g_return_val_if_fail( pSalAlpha->GetSize() == aSize, NULL ); - - int nX, nY; - guchar *pPixbufData = static_cast<guchar *>(g_malloc (4 * aSize.Width() * aSize.Height() )); - guchar *pDestData = pPixbufData; - - for( nY = 0; nY < pBitmap->mnHeight; nY++ ) - { - sal_uInt8 *pData = getRow( pBitmap, nY ); - sal_uInt8 *pAlphaData = getRow( pAlpha, nY ); - - for( nX = 0; nX < pBitmap->mnWidth; nX++ ) - { - BitmapColor aColor; - if (pBitmap->mnFormat == BMP_FORMAT_24BIT_TC_BGR) - { - aColor = BitmapColor(pData[2], pData[1], pData[0]); - pData += 3; - } - else if (pBitmap->mnFormat == BMP_FORMAT_24BIT_TC_RGB) - { - aColor = BitmapColor(pData[0], pData[1], pData[2]); - pData += 3; - } - else - { - pBitmap->maColorMask.GetColorFor32Bit(aColor, pData); - pData += 4; - } - *pDestData++ = aColor.GetRed(); - *pDestData++ = aColor.GetGreen(); - *pDestData++ = aColor.GetBlue(); - *pDestData++ = 255 - *pAlphaData++; - } - } - - pSalBitmap->ReleaseBuffer( pBitmap, BITMAP_READ_ACCESS ); - pSalAlpha->ReleaseBuffer( pAlpha, BITMAP_READ_ACCESS ); - - return gdk_pixbuf_new_from_data( pPixbufData, - GDK_COLORSPACE_RGB, true, 8, - aSize.Width(), aSize.Height(), - aSize.Width() * 4, - reinterpret_cast<GdkPixbufDestroyNotify>(g_free), - NULL ); -} - void GtkSalFrame::SetIcon( sal_uInt16 nIcon ) { if( (m_nStyle & (SalFrameStyleFlags::PLUG|SalFrameStyleFlags::SYSTEMCHILD|SalFrameStyleFlags::FLOAT|SalFrameStyleFlags::INTRO|SalFrameStyleFlags::OWNERDRAWDECORATION)) || ! m_pWindow ) return; - if( !ImplGetResMgr() ) - return; - - GdkPixbuf *pBuf; - GList *pIcons = NULL; - - sal_uInt16 nOffsets[2] = { SV_ICON_SMALL_START, SV_ICON_LARGE_START }; - sal_uInt16 nIndex; - - for( nIndex = 0; nIndex < sizeof(nOffsets)/ sizeof(sal_uInt16); nIndex++ ) - { - // #i44723# workaround gcc temporary problem - ResId aResId( nOffsets[nIndex] + nIcon, *ImplGetResMgr() ); - BitmapEx aIcon( aResId ); - - // #i81083# convert to 24bit/8bit alpha bitmap - Bitmap aBmp = aIcon.GetBitmap(); - if( aBmp.GetBitCount() != 24 || ! aIcon.IsAlpha() ) - { - if( aBmp.GetBitCount() != 24 ) - aBmp.Convert( BMP_CONVERSION_24BIT ); - AlphaMask aMask; - if( ! aIcon.IsAlpha() ) - { - switch( aIcon.GetTransparentType() ) - { - case TRANSPARENT_NONE: - { - sal_uInt8 nTrans = 0; - aMask = AlphaMask( aBmp.GetSizePixel(), &nTrans ); - } - break; - case TRANSPARENT_COLOR: - aMask = AlphaMask( aBmp.CreateMask( aIcon.GetTransparentColor() ) ); - break; - case TRANSPARENT_BITMAP: - aMask = AlphaMask( aIcon.GetMask() ); - break; - default: - OSL_FAIL( "unhandled transparent type" ); - break; - } - } - else - aMask = aIcon.GetAlpha(); - aIcon = BitmapEx( aBmp, aMask ); - } - - ImpBitmap *pIconImpBitmap = aIcon.ImplGetBitmapImpBitmap(); - ImpBitmap *pIconImpMask = aIcon.ImplGetMaskImpBitmap(); - - if( pIconImpBitmap && pIconImpMask ) - { - SalBitmap *pIconBitmap = - pIconImpBitmap->ImplGetSalBitmap(); - SalBitmap *pIconMask = - pIconImpMask->ImplGetSalBitmap(); - - if( ( pBuf = bitmapToPixbuf( pIconBitmap, pIconMask ) ) ) - pIcons = g_list_prepend( pIcons, pBuf ); - } - } - - gtk_window_set_icon_list( GTK_WINDOW(m_pWindow), pIcons ); + gchar* appicon; + + if (nIcon == SV_ICON_ID_TEXT) + appicon = g_strdup ("libreoffice-writer"); + else if (nIcon == SV_ICON_ID_SPREADSHEET) + appicon = g_strdup ("libreoffice-calc"); + else if (nIcon == SV_ICON_ID_DRAWING) + appicon = g_strdup ("libreoffice-draw"); + else if (nIcon == SV_ICON_ID_PRESENTATION) + appicon = g_strdup ("libreoffice-impress"); + else if (nIcon == SV_ICON_ID_DATABASE) + appicon = g_strdup ("libreoffice-base"); + else if (nIcon == SV_ICON_ID_FORMULA) + appicon = g_strdup ("libreoffice-math"); + else + appicon = g_strdup ("libreoffice-main"); - g_list_foreach( pIcons, reinterpret_cast<GFunc>(g_object_unref), NULL ); - g_list_free( pIcons ); + gtk_window_set_icon_name (GTK_WINDOW (m_pWindow), appicon); } void GtkSalFrame::SetMenu( SalMenu* pSalMenu ) |