[git] GpgOL - branch, outlook14, updated. gpgol-1.1.3-26-ge343c18

by Andre Heinecke cvs at cvs.gnupg.org
Fri Jul 12 13:17:18 CEST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, outlook14 has been updated
       via  e343c1843b4103749e20796aea94e90035a61bf5 (commit)
       via  1a5693177632f4cc7b7480aa0047de274ffab0d1 (commit)
      from  7d3eccb79093dab365b2e4124b98baacfa527671 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e343c1843b4103749e20796aea94e90035a61bf5
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 12 10:50:41 2013 +0000

    Load png images from resource for RibbonUi
    
        This uses gdiplus to convert the PNG data. It also
        simplyfies the invoke as the size is now taken
        from the resource file.
    
        * src/Makefile.am: Link gdiplus
        * src/gpgoladdin.cpp (Invoke): Just call getIcon for button
        callbacks
        * src/ribbon-callbacks.cpp (getIcon): Load images from resource
        as PNG and convert them.
        * src/ribbon-callbacks.h: Use png icons.

diff --git a/src/Makefile.am b/src/Makefile.am
index 137cc59..a385d5b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -118,7 +118,7 @@ gpgol_LDADD = $(srcdir)/gpgol.def  \
 	-L . -lgpgme -lassuan -lgpg-error \
 	-lmapi32 -lshell32 -lgdi32 -lcomdlg32 \
 	-lole32 -loleaut32 -lws2_32 -ladvapi32 \
-	-luuid
+	-luuid -lgdiplus
 
 resource.o: resource.rc versioninfo.rc dialogs.rc 
 
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index bd1368b..e6cde64 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -485,13 +485,10 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
       case ID_CMD_CERT_MANAGER:
         return startCertManager (parms->rgvarg[0].pdispVal);
       case ID_BTN_CERTMANAGER:
-        return getIcon (ID_BTN_CERTMANAGER, ICON_SIZE_LARGE, result);
       case ID_BTN_ENCRYPT:
-        return getIcon (ID_BTN_ENCRYPT, ICON_SIZE_NORMAL, result);
       case ID_BTN_DECRYPT:
-        return getIcon (ID_BTN_DECRYPT, ICON_SIZE_NORMAL, result);
       case ID_BTN_DECRYPT_LARGE:
-        return getIcon (ID_BTN_DECRYPT_LARGE, ICON_SIZE_LARGE, result);
+        return getIcon (dispid, result);
     }
 
   log_debug ("%s:%s: leave", SRCNAME, __func__);
diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index d1b6224..f686fa6 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -25,6 +25,7 @@
 #include <olectl.h>
 #include <stdio.h>
 #include <string.h>
+#include <gdiplus.h>
 
 #include <objidl.h>
 
@@ -626,52 +627,89 @@ decryptSelection (LPDISPATCH ctrl)
   return S_OK;
 }
 
+
+/* getIcon
+   Loads a PNG image from the resurce converts it into a Bitmap
+   and Wraps it in an PictureDispatcher that is returned as result.
+
+   Based on documentation from:
+   http://www.codeproject.com/Articles/3537/Loading-JPG-PNG-resources-using-GDI
+*/
+
 HRESULT
-getIcon (int id, int size, VARIANT* result)
+getIcon (int id, VARIANT* result)
 {
   PICTDESC pdesc;
   LPDISPATCH pPict;
   HRESULT hr;
   UINT fuload;
+  Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+  Gdiplus::Bitmap* pbitmap;
+  ULONG_PTR gdiplusToken;
+  HRSRC hResource;
+  DWORD imageSize;
+  const void* pResourceData;
+  HGLOBAL hBuffer;
 
   memset (&pdesc, 0, sizeof pdesc);
   pdesc.cbSizeofstruct = sizeof pdesc;
   pdesc.picType = PICTYPE_BITMAP;
 
-/*
-   In the future we might want to use PNGs here to have
-   full Alpha Channel support for the icons
-
-   Some explanation about images and transparency in Ribbons:
-   http://blogs.msdn.com/b/jensenh/archive/2006/11/27/ribbonx-image-faq.aspx
+  /* Initialize GDI */
+  gdiplusStartupInput.DebugEventCallback = NULL;
+  gdiplusStartupInput.SuppressBackgroundThread = FALSE;
+  gdiplusStartupInput.SuppressExternalCodecs = FALSE;
+  gdiplusStartupInput.GdiplusVersion = 1;
+  GdiplusStartup (&gdiplusToken, &gdiplusStartupInput, NULL);
 
-   Here is an example how this could look like with gdiplus:
+  /* Get the image from the resource file */
+  hResource = FindResource (glob_hinst, MAKEINTRESOURCE(id), RT_RCDATA);
+  if (!hResource)
+    {
+      log_error ("%s:%s: failed to find image: %i",
+                 SRCNAME, __func__, id);
+      return E_FAIL;
+    }
 
-   GdiplusStartupInput gdiplusStartupInput;
-   ULONG_PTR gdiplusToken;
-   Bitmap* pbitmap;
+  imageSize = SizeofResource (glob_hinst, hResource);
+  if (!imageSize)
+    return E_FAIL;
 
-   GetModuleFileName(glob_hinst, szModuleFileName, MAX_PATH);
+  pResourceData = LockResource (LoadResource(glob_hinst, hResource));
 
-   gdiplusStartupInput.DebugEventCallback = NULL;
-   gdiplusStartupInput.SuppressBackgroundThread = FALSE;
-   gdiplusStartupInput.SuppressExternalCodecs = FALSE;
-   gdiplusStartupInput.GdiplusVersion = 1;
-   GdiplusStartup (&gdiplusToken, &gdiplusStartupInput, NULL);
+  if (!pResourceData)
+    {
+      log_error ("%s:%s: failed to load image: %i",
+                 SRCNAME, __func__, id);
+      return E_FAIL;
+    }
 
-   pbitmap = Bitmap::FromFile (L"c:\\foo.png", FALSE);
-   if (!pbitmap || pbitmap->GetHBITMAP (0, &pdesc.bmp.hbitmap))
-     {
-       log_error ("%s:%s: failed to load file.",
-                  SRCNAME, __func__);
-     }
-*/
+  hBuffer = GlobalAlloc (GMEM_MOVEABLE, imageSize);
 
-  fuload = LR_CREATEDIBSECTION | LR_SHARED;
+  if (hBuffer)
+    {
+      void* pBuffer = GlobalLock (hBuffer);
+      if (pBuffer)
+        {
+          IStream* pStream = NULL;
+          CopyMemory (pBuffer, pResourceData, imageSize);
+
+          if (CreateStreamOnHGlobal (hBuffer, FALSE, &pStream) == S_OK)
+            {
+              pbitmap = Gdiplus::Bitmap::FromStream (pStream);
+              pStream->Release();
+              if (!pbitmap || pbitmap->GetHBITMAP (0, &pdesc.bmp.hbitmap))
+                {
+                  log_error ("%s:%s: failed to get PNG.",
+                             SRCNAME, __func__);
+                }
+            }
+        }
+      GlobalUnlock (pBuffer);
+    }
+  GlobalFree (hBuffer);
 
-  pdesc.bmp.hbitmap = (HBITMAP) LoadImage (glob_hinst,
-                                           MAKEINTRESOURCE (id),
-                                           IMAGE_BITMAP, size, size, fuload);
+  Gdiplus::GdiplusShutdown (gdiplusToken);
 
   /* Wrap the image into an OLE object.  */
   hr = OleCreatePictureIndirect (&pdesc, IID_IPictureDisp,
@@ -686,9 +724,6 @@ getIcon (int id, int size, VARIANT* result)
   result->pdispVal = pPict;
   result->vt = VT_DISPATCH;
 
-  /*
-  GdiplusShutdown (gdiplusToken);
-  */
 
   return S_OK;
 }
diff --git a/src/ribbon-callbacks.h b/src/ribbon-callbacks.h
index bf869a9..9396c0f 100644
--- a/src/ribbon-callbacks.h
+++ b/src/ribbon-callbacks.h
@@ -30,14 +30,15 @@
 #define ID_CMD_ENCRYPT_SELECTION 3
 #define ID_CMD_DECRYPT_SELECTION 4
 #define ID_CMD_CERT_MANAGER      5
-#define ID_BTN_CERTMANAGER       IDB_KEY_MANAGER_32
-#define ID_BTN_DECRYPT           IDB_DECRYPT_16
-#define ID_BTN_DECRYPT_LARGE     IDB_DECRYPT_32
-#define ID_BTN_ENCRYPT           IDB_ENCRYPT_16
+#define ID_BTN_CERTMANAGER       IDI_KEY_MANAGER_64_PNG
+#define ID_BTN_DECRYPT           IDI_DECRYPT_16_PNG
+#define ID_BTN_DECRYPT_LARGE     IDI_DECRYPT_48_PNG
+#define ID_BTN_ENCRYPT           IDI_ENCRYPT_16_PNG
+#define ID_BTN_ENCRYPT_LARGE     IDI_ENCRYPT_48_PNG
 
 HRESULT decryptAttachments (LPDISPATCH ctrl);
 HRESULT encryptSelection (LPDISPATCH ctrl);
 HRESULT decryptSelection (LPDISPATCH ctrl);
-HRESULT getIcon (int id, int size, VARIANT* result);
+HRESULT getIcon (int id, VARIANT* result);
 HRESULT startCertManager (LPDISPATCH ctrl);
 #endif

commit 1a5693177632f4cc7b7480aa0047de274ffab0d1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jul 12 10:47:36 2013 +0000

    Add png icons to be used in RibbonUI
    
        * src/Makefile.am (extra_dist): Add added Icons
        * src/README.icons: Add documentation
        * src/decrypt-16.png, src/decrypt-48.png, src/encrypt-16.png,
        src/encrypt-48.png, src/key-manager-64.png: New.
        * src/dialogs.h, src/dialogs.rc: Add new Ressources

diff --git a/src/Makefile.am b/src/Makefile.am
index 18c1355..137cc59 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,6 +30,9 @@ EXTRA_DIST = \
 	verify-32.bmp  verify-32m.bmp \
 	decrypt-verify-16.bmp decrypt-verify-16m.bmp \
 	decrypt-verify-32.bmp decrypt-verify-32m.bmp \
+	encrypt-16.png encrypt-48.png \
+	key-manager-64.png \
+	decrypt-16.png decrypt-48.png \
 	logo.bmp README.icons
 
 EXEEXT = .dll
diff --git a/src/README.icons b/src/README.icons
index c9a9979..3d55741 100644
--- a/src/README.icons
+++ b/src/README.icons
@@ -11,24 +11,30 @@ and those installed via the forms extensions from external files.
   ECE semi-documented way of installing icons.  This required a
   special palette (file Outlook.gpl) and the pink background colour as
   the transparency hack. Now we are using the OOM and things are much
-  easier. 
+  easier.
+
+  For Outlook 2010 and later versions we use PNG's directly with full
+  alpha channel support. They are converted to bitmaps in
+  ribbon-callbacks getIcon function.
 
   Icons are included by the resource compiler which reads the file
   dialogs.rc to create the resource.  This is all integtraged into the
   Makefile.  A sample entry in dialogs.rc looks like this:
 
     IDB_KEY_MANAGER_16        BITMAP  DISCARDABLE  "key-manager-16.bmp"
-    IDB_KEY_MANAGER_16M       BITMAP  DISCARDABLE  "key-manager-16m.bmp"     
-    IDB_KEY_MANAGER_32        BITMAP  DISCARDABLE  "key-manager-32.bmp"      
-    IDB_KEY_MANAGER_32M       BITMAP  DISCARDABLE  "key-manager-32m.bmp"      
-    //IDB_KEY_MANAGER_64        BITMAP  DISCARDABLE        
-    //IDB_KEY_MANAGER_64M       BITMAP  DISCARDABLE        
+    IDB_KEY_MANAGER_16M       BITMAP  DISCARDABLE  "key-manager-16m.bmp"
+    IDB_KEY_MANAGER_32        BITMAP  DISCARDABLE  "key-manager-32.bmp"
+    IDB_KEY_MANAGER_32M       BITMAP  DISCARDABLE  "key-manager-32m.bmp"
+    //IDB_KEY_MANAGER_64        BITMAP  DISCARDABLE
+    //IDB_KEY_MANAGER_64M       BITMAP  DISCARDABLE
+    IDI_KEY_MANAGER_64_PNG    RCDATA               "key-manager-64.png"
 
   This is the icon for the certificate manager.  We provide two
   resolutions: 16x16 and 32x32 pixel.  I have not yet encountered the
   32x32 thus most other icons are only available in the 16x16 variant.
   The IDB_foo identifiers are defined in dialogs.h; see the comments
   at the top of that file for details.
+  PNG icons have to be added with the type RCDATA.
 
   For compatibility with OL2003 we can't use PNGs directly but we need
   to provide bitmaps and a mask for transparency.
diff --git a/src/decrypt-16.png b/src/decrypt-16.png
new file mode 100644
index 0000000..8ebe5b1
Binary files /dev/null and b/src/decrypt-16.png differ
diff --git a/src/decrypt-48.png b/src/decrypt-48.png
new file mode 100644
index 0000000..2dfad6a
Binary files /dev/null and b/src/decrypt-48.png differ
diff --git a/src/dialogs.h b/src/dialogs.h
index a950c44..314047d 100644
--- a/src/dialogs.h
+++ b/src/dialogs.h
@@ -134,6 +134,11 @@
 #define IDC_VRY_AKALIST                 4420
 #define IDC_VRY_HINT                    4421
 
-
+/* Ids for PNG Images */
+#define IDI_ENCRYPT_16_PNG              6000
+#define IDI_ENCRYPT_48_PNG              6001
+#define IDI_DECRYPT_16_PNG              6010
+#define IDI_DECRYPT_48_PNG              6011
+#define IDI_KEY_MANAGER_64_PNG          6020
 
 #endif /*DIALOGS_H*/
diff --git a/src/dialogs.rc b/src/dialogs.rc
index 357d595..586ebdb 100644
--- a/src/dialogs.rc
+++ b/src/dialogs.rc
@@ -24,31 +24,36 @@
 
 
 IDB_ENCRYPT_16            BITMAP  DISCARDABLE  "encrypt-16.bmp"
-IDB_ENCRYPT_16M           BITMAP  DISCARDABLE  "encrypt-16m.bmp"      
+IDB_ENCRYPT_16M           BITMAP  DISCARDABLE  "encrypt-16m.bmp"
 IDB_ENCRYPT_32            BITMAP  DISCARDABLE  "encrypt-32.bmp"
-IDB_ENCRYPT_32M           BITMAP  DISCARDABLE  "encrypt-32m.bmp"      
+IDB_ENCRYPT_32M           BITMAP  DISCARDABLE  "encrypt-32m.bmp"
+IDI_ENCRYPT_16_PNG        RCDATA               "encrypt-16.png"
+IDI_ENCRYPT_48_PNG        RCDATA               "encrypt-48.png"
 
 IDB_SIGN_16               BITMAP  DISCARDABLE  "sign-16.bmp"
-IDB_SIGN_16M              BITMAP  DISCARDABLE  "sign-16m.bmp"      
-IDB_SIGN_32               BITMAP  DISCARDABLE  "sign-32.bmp"      
-IDB_SIGN_32M              BITMAP  DISCARDABLE  "sign-32m.bmp"      
+IDB_SIGN_16M              BITMAP  DISCARDABLE  "sign-16m.bmp"
+IDB_SIGN_32               BITMAP  DISCARDABLE  "sign-32.bmp"
+IDB_SIGN_32M              BITMAP  DISCARDABLE  "sign-32m.bmp"
 
 IDB_KEY_MANAGER_16        BITMAP  DISCARDABLE  "key-manager-16.bmp"
-IDB_KEY_MANAGER_16M       BITMAP  DISCARDABLE  "key-manager-16m.bmp"     
-IDB_KEY_MANAGER_32        BITMAP  DISCARDABLE  "key-manager-32.bmp"      
-IDB_KEY_MANAGER_32M       BITMAP  DISCARDABLE  "key-manager-32m.bmp"      
-IDB_KEY_MANAGER_64        BITMAP  DISCARDABLE  "key-manager-64.bmp"      
+IDB_KEY_MANAGER_16M       BITMAP  DISCARDABLE  "key-manager-16m.bmp"
+IDB_KEY_MANAGER_32        BITMAP  DISCARDABLE  "key-manager-32.bmp"
+IDB_KEY_MANAGER_32M       BITMAP  DISCARDABLE  "key-manager-32m.bmp"
+IDB_KEY_MANAGER_64        BITMAP  DISCARDABLE  "key-manager-64.bmp"
 IDB_KEY_MANAGER_64M       BITMAP  DISCARDABLE  "key-manager-64m.bmp"
+IDI_KEY_MANAGER_64_PNG    RCDATA               "key-manager-64.png"
 
 IDB_DECRYPT_16            BITMAP  DISCARDABLE  "decrypt-16.bmp"
-IDB_DECRYPT_16M           BITMAP  DISCARDABLE  "decrypt-16m.bmp"     
+IDB_DECRYPT_16M           BITMAP  DISCARDABLE  "decrypt-16m.bmp"
 IDB_DECRYPT_32            BITMAP  DISCARDABLE  "decrypt-32.bmp"
 IDB_DECRYPT_32M           BITMAP  DISCARDABLE  "decrypt-32m.bmp"
+IDI_DECRYPT_16_PNG        RCDATA               "decrypt-16.png"
+IDI_DECRYPT_48_PNG        RCDATA               "decrypt-48.png"
 
-IDB_VERIFY_16             BITMAP  DISCARDABLE  "verify-16.bmp"          
-IDB_VERIFY_16M            BITMAP  DISCARDABLE  "verify-16m.bmp"     
-IDB_VERIFY_32             BITMAP  DISCARDABLE  "verify-32.bmp"      
-IDB_VERIFY_32M            BITMAP  DISCARDABLE  "verify-32m.bmp"      
+IDB_VERIFY_16             BITMAP  DISCARDABLE  "verify-16.bmp"
+IDB_VERIFY_16M            BITMAP  DISCARDABLE  "verify-16m.bmp"
+IDB_VERIFY_32             BITMAP  DISCARDABLE  "verify-32.bmp"
+IDB_VERIFY_32M            BITMAP  DISCARDABLE  "verify-32m.bmp"
 
 IDB_DECRYPT_VERIFY_16     BITMAP  DISCARDABLE  "decrypt-verify-16.bmp" 
 IDB_DECRYPT_VERIFY_16M    BITMAP  DISCARDABLE  "decrypt-verify-16m.bmp"
diff --git a/src/encrypt-16.png b/src/encrypt-16.png
new file mode 100644
index 0000000..403f4a7
Binary files /dev/null and b/src/encrypt-16.png differ
diff --git a/src/encrypt-48.png b/src/encrypt-48.png
new file mode 100644
index 0000000..fb27604
Binary files /dev/null and b/src/encrypt-48.png differ
diff --git a/src/key-manager-64.png b/src/key-manager-64.png
new file mode 100644
index 0000000..38b7ed0
Binary files /dev/null and b/src/key-manager-64.png differ

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am          |    5 ++-
 src/README.icons         |   18 ++++++---
 src/decrypt-16.png       |  Bin 0 -> 418 bytes
 src/decrypt-48.png       |  Bin 0 -> 2104 bytes
 src/dialogs.h            |    7 +++-
 src/dialogs.rc           |   33 +++++++++-------
 src/encrypt-16.png       |  Bin 0 -> 383 bytes
 src/encrypt-48.png       |  Bin 0 -> 2474 bytes
 src/gpgoladdin.cpp       |    5 +--
 src/key-manager-64.png   |  Bin 0 -> 3361 bytes
 src/ribbon-callbacks.cpp |   97 +++++++++++++++++++++++++++++++---------------
 src/ribbon-callbacks.h   |   11 +++--
 12 files changed, 114 insertions(+), 62 deletions(-)
 create mode 100644 src/decrypt-16.png
 create mode 100644 src/decrypt-48.png
 create mode 100644 src/encrypt-16.png
 create mode 100644 src/encrypt-48.png
 create mode 100644 src/key-manager-64.png


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list