[svn] GpgEX - r9 - in trunk: . m4 src
svn author marcus
cvs at cvs.gnupg.org
Mon Sep 3 23:52:05 CEST 2007
Author: marcus
Date: 2007-09-03 23:51:34 +0200 (Mon, 03 Sep 2007)
New Revision: 9
Added:
trunk/src/bitmaps.cc
trunk/src/bitmaps.h
trunk/src/icon-key-12.bmp
trunk/src/icon-key-16.bmp
trunk/src/icons.rc
Modified:
trunk/ChangeLog
trunk/m4/Makefile.am
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/gpgex.cc
trunk/src/gpgex.h
Log:
m4/
2007-09-03 Marcus Brinkmann <marcus at g10code.de>
* m4/Makefile.am (EXTRA_DIST): Remove gpgme.m4 and gpg-error.m4.
src/
2007-09-03 Marcus Brinkmann <marcus at g10code.de>
* bitmaps.h, bitmaps.cc, icons.rc, icon-key-12.bmp,
icon-key-16.bmp: New files.
* Makefile.am (gpgex_SOURCES): Add icons.rc, bitmaps.h and
bitmaps.cc.
(noinst_gpgex_SOURCES): Add versioninfo.rc.
(gpgex_LDADD): Add -lgdi32.
(resource.o): Remove target.
* gpgex.h: Include bitmaps.h.
(class gpgex_t): New member key_bitmap.
(gpgex_t::gpgex_t, gpgex_t::~gpgex_t): Initialize and deinitialize
it.
* gpgex.cc (gpgex_t::QueryContextMenu): Add dummy bitmap for menu.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/ChangeLog 2007-09-03 21:51:34 UTC (rev 9)
@@ -1,3 +1,7 @@
+2007-09-03 Marcus Brinkmann <marcus at g10code.de>
+
+ * m4/Makefile.am (EXTRA_DIST): Remove gpgme.m4 and gpg-error.m4.
+
2007-08-23 Marcus Brinkmann <marcus at g10code.de>
* Initial commit.
Modified: trunk/m4/Makefile.am
===================================================================
--- trunk/m4/Makefile.am 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/m4/Makefile.am 2007-09-03 21:51:34 UTC (rev 9)
@@ -1,4 +1,4 @@
-EXTRA_DIST = gpgme.m4 codeset.m4 gettext.m4 glibc21.m4 gpg-error.m4 \
- iconv.m4 intdiv0.m4 inttypes-pri.m4 inttypes.m4 inttypes_h.m4 \
- isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 \
- nls.m4 po.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
+EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 \
+ inttypes-pri.m4 inttypes.m4 inttypes_h.m4 isc-posix.m4 \
+ lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4 \
+ po.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/src/ChangeLog 2007-09-03 21:51:34 UTC (rev 9)
@@ -1,3 +1,18 @@
+2007-09-03 Marcus Brinkmann <marcus at g10code.de>
+
+ * bitmaps.h, bitmaps.cc, icons.rc, icon-key-12.bmp,
+ icon-key-16.bmp: New files.
+ * Makefile.am (gpgex_SOURCES): Add icons.rc, bitmaps.h and
+ bitmaps.cc.
+ (noinst_gpgex_SOURCES): Add versioninfo.rc.
+ (gpgex_LDADD): Add -lgdi32.
+ (resource.o): Remove target.
+ * gpgex.h: Include bitmaps.h.
+ (class gpgex_t): New member key_bitmap.
+ (gpgex_t::gpgex_t, gpgex_t::~gpgex_t): Initialize and deinitialize
+ it.
+ * gpgex.cc (gpgex_t::QueryContextMenu): Add dummy bitmap for menu.
+
2007-08-31 Marcus Brinkmann <marcus at g10code.de>
* gpgex.cc (gpgex_t::QueryContextMenu): Fix menu separators.
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/src/Makefile.am 2007-09-03 21:51:34 UTC (rev 9)
@@ -18,21 +18,22 @@
AM_CFLAGS = $(GPGME_CFLAGS) -shared
AM_CXXFLAGS = $(GPGME_CFLAGS) -shared
-gpgex_SOURCES = \
+nodist_gpgex_SOURCES = versioninfo.rc
+gpgex_SOURCES = \
gpgex.def \
+ icons.rc \
registry.h registry.c \
w32-gettext.c w32-gettext.h \
gpgex-class.h gpgex-class.cc \
gpgex-factory.h gpgex-factory.cc \
+ bitmaps.h bitmaps.cc \
gpgex.h gpgex.cc \
main.h main.cc
#gpgex_LDADD = $(srcdir)/gpgex.def \
-# -L . -lshell32 -lgdi32 -lcomdlg32 \
-# -loleaut32 -lws2_32 -ladvapi32
-gpgex_LDADD = $(srcdir)/gpgex.def -L . -lshell32 -lws2_32 -lole32 -luuid
+# -L . -lshell32 -lcomdlg32 -loleaut32 -ladvapi32
+gpgex_LDADD = $(srcdir)/gpgex.def -L . \
+ -lshell32 -lgdi32 -lws2_32 -lole32 -luuid
-resource.o: versioninfo.rc
-
.rc.o:
$(WINDRES) -I $(srcdir) -I . `test -f '$<' || echo '$(srcdir)/'`$< $@
Added: trunk/src/bitmaps.cc
===================================================================
--- trunk/src/bitmaps.cc 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/src/bitmaps.cc 2007-09-03 21:51:34 UTC (rev 9)
@@ -0,0 +1,94 @@
+/* bitmaps.cc - gpgex bitmap implementation
+ Copyright (C) 2007 g10 Code GmbH
+
+ This file is part of GpgEX.
+
+ GpgEX is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ GpgEX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+#include <sstream>
+
+using std::string;
+
+#include <windows.h>
+
+#include "main.h"
+
+#include "bitmaps.h"
+
+
+/* The size of the icons. */
+int gpgex_bitmaps_t::size;
+
+/* The available bitmap sizes in ascending order. */
+int gpgex_bitmaps_t::available_sizes[] = { 12, 16 };
+
+
+/* The global singleton object. */
+class gpgex_bitmaps_t gpgex_bitmaps;
+
+
+gpgex_bitmaps_t::gpgex_bitmaps_t (void)
+{
+ /* Note about bitmaps: The required size is given by
+ GetSystemMetrics and can vary depending on the display size. A
+ typical value is 12x12. The color depth should be 8 bits. The
+ upper left corner pixel color is replaced by transparent
+ automatically. */
+ int width = GetSystemMetrics (SM_CXMENUCHECK);
+ int height = GetSystemMetrics (SM_CYMENUCHECK);
+
+ /* All our images are square, so take the minimum and look for the
+ biggest available size that fits in there. */
+ int max_size = (width < height) ? width : height;
+
+ for (unsigned int i = 0; i < (sizeof (this->available_sizes)
+ / sizeof (this->available_sizes[0])); i++)
+ if (max_size >= this->available_sizes[i])
+ this->size = this->available_sizes[i];
+ else
+ break;
+
+ (void) TRACE3 (DEBUG_INIT, "gpgex_bitmaps_t::gpgex_bitmaps_t", this,
+ "GetSystemMetrics: %ix%i (using %i)", width, height,
+ this->size);
+}
+
+
+/* Load the bitmap with name NAME. */
+HBITMAP gpgex_bitmaps_t::load_bitmap (string name)
+{
+ HBITMAP bmap;
+ std::ostringstream out;
+
+ out << name << "-" << this->size;
+ bmap = LoadBitmap (gpgex_server::instance, out.str().c_str());
+ if (bmap == NULL)
+ (void) TRACE2 (DEBUG_INIT, "gpgex_bitmaps_t::load_bitmap", this,
+ "LoadImage %s failed: ec=%x",
+ out.str().c_str(), GetLastError ());
+ else
+ (void) TRACE1 (DEBUG_INIT, "gpgex_bitmaps_t::load_bitmap", this,
+ "loaded image %s", out.str().c_str());
+
+ /* FIXME: Create cache of images. */
+ return bmap;
+}
+
Added: trunk/src/bitmaps.h
===================================================================
--- trunk/src/bitmaps.h 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/src/bitmaps.h 2007-09-03 21:51:34 UTC (rev 9)
@@ -0,0 +1,52 @@
+/* bitmaps.h - gpgex bitmap prototypes
+ Copyright (C) 2007 g10 Code GmbH
+
+ This file is part of GpgEX.
+
+ GpgEX is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ GpgEX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#ifndef GPGEX_BITMAPS_H
+#define GPGEX_BITMAPS_H
+
+#include <string>
+
+using std::string;
+
+#include <windows.h>
+
+
+/* The class used to load bitmap resources. */
+class gpgex_bitmaps_t
+{
+ /* The icon size used. */
+ static int size;
+
+ /* The available sizes. */
+ static int available_sizes[];
+
+ public:
+ /* Constructor. */
+ gpgex_bitmaps_t (void);
+
+ /* Load the bitmap with name NAME. */
+ HBITMAP load_bitmap (string name);
+};
+
+
+/* The global singleton object. */
+extern gpgex_bitmaps_t gpgex_bitmaps;
+
+#endif /* ! GPGEX_BITMAPS_H */
Modified: trunk/src/gpgex.cc
===================================================================
--- trunk/src/gpgex.cc 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/src/gpgex.cc 2007-09-03 21:51:34 UTC (rev 9)
@@ -278,16 +278,21 @@
return TRACE_RES (HRESULT_FROM_WIN32 (last_error));
}
- res = InsertMenu (hMenu, indexMenu++, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
+ if (this->key_bitmap)
+ {
+ // indexMenu - 1!!!
+ res = SetMenuItemBitmaps (hMenu, indexMenu - 1, MF_BYPOSITION,
+ this->key_bitmap, this->key_bitmap);
+ }
+ if (res)
+ res = InsertMenu (hMenu, indexMenu++, MF_BYPOSITION | MF_SEPARATOR,
+ 0, NULL);
if (! res)
return TRACE_RES (HRESULT_FROM_WIN32 (GetLastError ()));
res = InsertMenu (popup, idx++, MF_BYPOSITION | MF_STRING,
idCmdFirst + ID_CMD_VERIFY_DECRYPT,
ID_CMD_STR_VERIFY_DECRYPT);
- // idx - 1!!!
- // res = SetMenuItemBitmaps (hPopup, idx - 1, MF_BYPOSITION,
- // MenuVerifyDecryptBitmap, MenuVerifyDecryptBitmap);
if (res)
res = InsertMenu (popup, idx++, MF_BYPOSITION | MF_STRING,
Modified: trunk/src/gpgex.h
===================================================================
--- trunk/src/gpgex.h 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/src/gpgex.h 2007-09-03 21:51:34 UTC (rev 9)
@@ -30,6 +30,8 @@
#include <windows.h>
#include <shlobj.h>
+#include "bitmaps.h"
+
/* For context menus. */
#define ID_CMD_HELP 0
#define ID_CMD_VERIFY_DECRYPT 1
@@ -100,19 +102,33 @@
BOOL all_files_gpg;
/* Support for the context menu. */
-
+ HBITMAP key_bitmap;
+
public:
/* Constructors and destructors. For these, we update the global
component reference counter. */
- gpgex_t ()
+ gpgex_t (void)
: refcount (0)
{
+ TRACE_BEG (DEBUG_INIT, "gpgex_t::gpgex_t", this);
+
gpgex_server::add_ref ();
+
+ this->key_bitmap = gpgex_bitmaps.load_bitmap ("Key");
+
+ (void) TRACE_SUC ();
}
- ~gpgex_t ()
+ ~gpgex_t (void)
{
+ TRACE_BEG (DEBUG_INIT, "gpgex_t::~gpgex_t", this);
+
+ if (this->key_bitmap != NULL)
+ DeleteObject (this->key_bitmap);
+
gpgex_server::release ();
+
+ (void) TRACE_SUC ();
}
/* Reset the instance between operations. */
Added: trunk/src/icon-key-12.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/src/icon-key-12.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/icon-key-16.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/src/icon-key-16.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/icons.rc
===================================================================
--- trunk/src/icons.rc 2007-08-31 21:59:38 UTC (rev 8)
+++ trunk/src/icons.rc 2007-09-03 21:51:34 UTC (rev 9)
@@ -0,0 +1,2 @@
+Key-12 BITMAP "icon-key-12.bmp"
+Key-16 BITMAP "icon-key-16.bmp"
More information about the Gnupg-commits
mailing list