summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSimon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>2015-10-26 13:41:32 +0100
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2015-10-26 13:23:37 +0000
commitac5b2047ca72677d6beaf58ddaa8fdcda7236292 (patch)
tree999f2ff299b3b73ef7f157ccc5109700dc7d8f49 /sfx2
parent5b4c29b1b15dcebfe4e76aaa8bdb2dd45e2b67f3 (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 'sfx2')
-rw-r--r--sfx2/source/appl/shutdowniconunx.cxx80
1 files changed, 18 insertions, 62 deletions
diff --git a/sfx2/source/appl/shutdowniconunx.cxx b/sfx2/source/appl/shutdowniconunx.cxx
index 2de5654fe28a..fc2921cb788e 100644
--- a/sfx2/source/appl/shutdowniconunx.cxx
+++ b/sfx2/source/appl/shutdowniconunx.cxx
@@ -27,8 +27,6 @@
#include <glib.h>
#include <osl/mutex.hxx>
#include <osl/module.hxx>
-#include <vcl/bitmapex.hxx>
-#include <vcl/bmpacc.hxx>
#include "tools/rc.hxx"
#include <sfx2/app.hxx>
#include "app.hrc"
@@ -42,9 +40,6 @@
#endif
// Cut/paste from vcl/inc/svids.hrc
-#define SV_ICON_SMALL_START 25000
-
-#define SV_ICON_ID_OFFICE 1
#define SV_ICON_ID_TEXT 2
#define SV_ICON_ID_SPREADSHEET 4
#define SV_ICON_ID_DRAWING 6
@@ -108,57 +103,6 @@ static void menu_deactivate_cb( GtkWidget *pMenu )
gtk_menu_popdown( GTK_MENU( pMenu ) );
}
-static GdkPixbuf * ResIdToPixbuf( sal_uInt16 nResId )
-{
- ResId aResId( nResId, *pVCLResMgr );
- BitmapEx aIcon( aResId );
- Bitmap pInSalBitmap = aIcon.GetBitmap();
- AlphaMask pInSalAlpha = aIcon.GetAlpha();
-
- if( pInSalBitmap.GetBitCount() != 24 )
- pInSalBitmap.Convert( BMP_CONVERSION_24BIT );
-
- Bitmap::ScopedReadAccess pSalBitmap(pInSalBitmap);
- AlphaMask::ScopedReadAccess pSalAlpha(pInSalAlpha);
-
- g_return_val_if_fail( pSalBitmap, NULL );
-
- Size aSize( pSalBitmap->Width(), pSalBitmap->Height() );
- if (pSalAlpha)
- g_return_val_if_fail( Size( pSalAlpha->Width(), pSalAlpha->Height() ) == aSize, NULL );
-
- int nX, nY;
- guchar *pPixbufData = static_cast<guchar *>(g_malloc( 4 * aSize.Width() * aSize.Height() ));
- guchar *pDestData = pPixbufData;
-
- for( nY = 0; nY < pSalBitmap->Height(); nY++ )
- {
- for( nX = 0; nX < pSalBitmap->Width(); nX++ )
- {
- BitmapColor aPix;
- aPix = pSalBitmap->GetPixel( nY, nX );
- pDestData[0] = aPix.GetRed();
- pDestData[1] = aPix.GetGreen();
- pDestData[2] = aPix.GetBlue();
- if (pSalAlpha)
- {
- aPix = pSalAlpha->GetPixel( nY, nX );
- pDestData[3] = 255 - aPix.GetIndex();
- }
- else
- pDestData[3] = 255;
- pDestData += 4;
- }
- }
-
- return gdk_pixbuf_new_from_data( pPixbufData,
- GDK_COLORSPACE_RGB, sal_True, 8,
- aSize.Width(), aSize.Height(),
- aSize.Width() * 4,
- reinterpret_cast<GdkPixbufDestroyNotify>(g_free),
- NULL );
-}
-
extern "C" {
static void oustring_delete (gpointer data,
GClosure * /* closure */)
@@ -183,10 +127,24 @@ static void add_item( GtkMenuShell *pMenuShell, const char *pAsciiURL,
RTL_TEXTENCODING_UTF8);
}
- GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_SMALL_START + nResId );
- GtkWidget *pImage = gtk_image_new_from_pixbuf( pPixbuf );
- g_object_unref( G_OBJECT( pPixbuf ) );
+ gchar* appicon;
+
+ if (nResId == SV_ICON_ID_TEXT)
+ appicon = g_strdup ("libreoffice-writer");
+ else if (nResId == SV_ICON_ID_SPREADSHEET)
+ appicon = g_strdup ("libreoffice-calc");
+ else if (nResId == SV_ICON_ID_DRAWING)
+ appicon = g_strdup ("libreoffice-draw");
+ else if (nResId == SV_ICON_ID_PRESENTATION)
+ appicon = g_strdup ("libreoffice-impress");
+ else if (nResId == SV_ICON_ID_DATABASE)
+ appicon = g_strdup ("libreoffice-base");
+ else if (nResId == SV_ICON_ID_FORMULA)
+ appicon = g_strdup ("libreoffice-math");
+ else
+ appicon = g_strdup ("libreoffice-main");
+ GtkWidget *pImage = gtk_image_new_from_icon_name (appicon, GTK_ICON_SIZE_MENU);
GtkWidget *pMenuItem = gtk_image_menu_item_new_with_label( aLabel.getStr() );
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM( pMenuItem ), pImage );
g_signal_connect_data( pMenuItem, "activate", pFnCallback, pURL,
@@ -383,9 +341,7 @@ void plugin_init_sys_tray()
pVCLResMgr = ResMgr::CreateResMgr("vcl");
- GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_SMALL_START + SV_ICON_ID_OFFICE );
- pTrayIcon = gtk_status_icon_new_from_pixbuf(pPixbuf);
- g_object_unref( pPixbuf );
+ pTrayIcon = gtk_status_icon_new_from_icon_name ("libreoffice-main");
g_object_set (pTrayIcon, "title", aLabel.getStr(),
"tooltip_text", aLabel.getStr(), NULL);