[Winpt-commits] r236 - trunk/Src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jun 28 08:59:32 CEST 2006


Author: twoaday
Date: 2006-06-28 08:59:30 +0200 (Wed, 28 Jun 2006)
New Revision: 236

Modified:
   trunk/Src/ChangeLog
   trunk/Src/WinPT-en.rc
   trunk/Src/resource.h
   trunk/Src/wptClipDecryptDlg.cpp
   trunk/Src/wptClipEditDlg.cpp
   trunk/Src/wptClipEncryptDlg.cpp
   trunk/Src/wptKeyEditDlgs.cpp
   trunk/Src/wptKeylist.cpp
   trunk/Src/wptListView.cpp
   trunk/Src/wptTrayPop.cpp
Log:


Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/ChangeLog	2006-06-28 06:59:30 UTC (rev 236)
@@ -1,3 +1,17 @@
+
+2006-06-27  Timo Schulz  <ts at g10code.de>
+
+	* wptClipDecryptDlg.cpp (clip_decrypt_dlg): Also call viewer
+	when no sig has been found (if requested).
+	* wptClipEditDlg.cpp (clip_edit_dlg_proc): Use a button to
+	quote instead of the check box. Cleanups.
+	* wptClipEncryptDlg.cpp (clip_encrypt_dlg_proc): Correct
+	sorting problem and wrong icon display.
+	* wptListView.cpp (listview_sort_items): Correct code for
+	checkbox based lists.
+	* wptKeylist.cpp (keylist_build): Add sorting icons.
+	* wptKeyEditDlgs.cpp (create_header_tooltip): New.
+	
 2006-06-24  Timo Schulz  <ts at g10code.de>
 
 	* wptMainProc.cpp (winpt_main_proc): Localize missing string.

Modified: trunk/Src/WinPT-en.rc
===================================================================
--- trunk/Src/WinPT-en.rc	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/WinPT-en.rc	2006-06-28 06:59:30 UTC (rev 236)
@@ -306,8 +306,7 @@
     CONTROL         "",IDC_CLIPEDIT_CLIPTEXT2,"RICHEDIT",ES_MULTILINE | 
                     ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP,6,6,
                     319,208
-    CONTROL         "Add quotes",IDC_CLIPEDIT_QUOTE,"Button",BS_AUTOCHECKBOX | 
-                    WS_TABSTOP,7,216,66,10
+    PUSHBUTTON      "&Quote",IDC_CLIPEDIT_QUOTE,7,218,31,15
     PUSHBUTTON      "&Copy",IDC_CLIPEDIT_SEND,100,217,42,15
     PUSHBUTTON      "Clea&r",IDC_CLIPEDIT_CLEAR,144,217,42,15
     PUSHBUTTON      "&Save",IDC_CLIPEDIT_SAVE,187,217,42,15

Modified: trunk/Src/resource.h
===================================================================
--- trunk/Src/resource.h	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/resource.h	2006-06-28 06:59:30 UTC (rev 236)
@@ -845,7 +845,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        250
 #define _APS_NEXT_COMMAND_VALUE         40190
-#define _APS_NEXT_CONTROL_VALUE         1536
+#define _APS_NEXT_CONTROL_VALUE         1537
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: trunk/Src/wptClipDecryptDlg.cpp
===================================================================
--- trunk/Src/wptClipDecryptDlg.cpp	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/wptClipDecryptDlg.cpp	2006-06-28 06:59:30 UTC (rev 236)
@@ -204,7 +204,6 @@
     gpgme_decrypt_result_t res;
     gpgme_verify_result_t sigres;
     passphrase_cb_s pwd;
-    const char *s;    
     int pgp_type = 0;
 
     /* allow to verify data generated by 'gpg -a --sign foo' */
@@ -252,14 +251,17 @@
 	goto leave;
     }
 
-    if (0) { /* XXX: Bad MDC */
-	s = _("WARNING: encrypted message has been manipulated!\n"
+    #if 0
+    if (status_bad_mdc) { /* XXX: Bad MDC */
+	const char *s = 
+	    _("WARNING: encrypted message has been manipulated!\n"
 	    "\n"
 	    "Do *NOT* trust any text or data output from this file!\n"
 	    "It is likely, the data was corrupted during the transport\n"
 	    "but it might be also possible that this is part of an attack.");
 	msg_box (hwnd, s, _("*** IMPORTANT ***"), MB_INFO);
     }
+    #endif
 
     show_msg (GetDesktopWindow (), 1500, _("GnuPG Status: Finished"));
 
@@ -272,6 +274,9 @@
 			    hwnd, clip_edit_dlg_proc, 
 			    (LPARAM)sigres->signatures);
     }
+    else if (use_viewer)
+	DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CLIPEDIT,
+			    hwnd, clip_edit_dlg_proc, 0);
 
 leave:
     release_gpg_passphrase_cb (&pwd);

Modified: trunk/Src/wptClipEditDlg.cpp
===================================================================
--- trunk/Src/wptClipEditDlg.cpp	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/wptClipEditDlg.cpp	2006-06-28 06:59:30 UTC (rev 236)
@@ -48,6 +48,10 @@
 #endif
 
 
+void verify_get_clip_info (gpgme_signature_t sig, 
+			   char **r_header, char **r_footer);
+
+
 /* Load the clipboard contents into the text field in @dlg.
    Optinally @header and @footer can be used to set a header and footer.
    Return value: 0 on success. */
@@ -136,7 +140,7 @@
 	if (!fp) {
 	    msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN), 
 		     _("Clipboard"), MB_ERR);
-	    return FALSE;
+	    return -1;
 	}
 	p = new char[size+1];
 	if (!p)
@@ -166,9 +170,9 @@
     save.lStructSize = sizeof (OPENFILENAME);	    
     save.hInstance = glob_hinst;	    
     save.lpstrTitle = _("File Save");	    
-    save.lpstrFile = (char *)"All Files (*.*)\0*.*\0\0";
-    save.hwndOwner = dlg;		    
-    save.lpstrFile = file;		    
+    save.lpstrFile = "All Files (*.*)\0*.*\0\0";
+    save.hwndOwner = dlg;
+    save.lpstrFile = file;
     save.nMaxFile = sizeof (file) - 1;
     save.Flags = OFN_OVERWRITEPROMPT;
 
@@ -177,16 +181,15 @@
 	    id = log_box (_("Clipboard"), MB_YESNO,
 			  _("\"%s\" already exists.\n"
 			    "Replace existing file?"), file);	    
-	    if( id == IDNO )	
-		return FALSE;
+	    if (id == IDNO)	
+		return -1;
 	}
 	fp = fopen (file, "wb");
 	if (!fp) {
 	    msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT), 
 		     _("Clipboard"), MB_ERR);
-	    return FALSE;
+	    return -1;
 	}
-	/* XXX: there is a NUL-byte at the end. */
 	nbytes = SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, 
 				     WM_GETTEXTLENGTH, 0, 0);
 	if (nbytes > 0) {
@@ -204,14 +207,12 @@
 }
 
 
-void verify_get_clip_info (gpgme_signature_t sig, 
-			   char **r_header, char **r_footer);
-
 /* Dialog box procedure for the clipboard editor. */
 BOOL CALLBACK 
 clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {
     char *head=NULL, *foot=NULL;
+    gpgme_data_t txt;
 
     switch (msg)  {
     case WM_INITDIALOG:
@@ -221,8 +222,9 @@
 	SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r"));
 	SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load"));	
 	SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save"));
-	SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes")); 
+	SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("&Quote")); 
 	SetDlgItemText (dlg, IDOK, _("&Close"));
+
 	/* If there is a param, we expect a signature and initialize
 	   the header and footer variable accordingly. */
 	if (lparam)
@@ -248,15 +250,15 @@
 	    EndDialog (dlg, TRUE);
 	    return TRUE;
             
+	case IDC_CLIPEDIT_QUOTE:
+	    if (gpg_data_new_from_clipboard (&txt, 0))
+		return TRUE;
+	    gpg_data_mail_quote (&txt);
+	    gpg_data_release_and_set_clipboard (txt, 0);
+	    load_clipboard (dlg, head, foot);
+	    return TRUE;
+
 	case IDC_CLIPEDIT_SEND:
-	    if (IsDlgButtonChecked (dlg, IDC_CLIPEDIT_QUOTE)) {
-		gpgme_data_t txt;
-		gpg_data_new_from_clipboard (&txt, 0);
-		gpg_data_mail_quote (&txt);
-		gpg_data_release_and_set_clipboard (txt, 0);
-		SendMessage (dlg, WM_INITDIALOG, 0, 0);
-		return TRUE;
-	    }
 	    SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, EM_SETSEL, 0, -1);
 	    SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, WM_COPY, 0, 0);
 	    return TRUE;
@@ -276,10 +278,8 @@
 	    return TRUE;
             
 	case IDC_CLIPEDIT_LOAD:
-	    if (!load_clipboard_from_file (dlg)) {
-		CheckDlgButton (dlg, IDC_CLIPEDIT_QUOTE, BST_UNCHECKED);
+	    if (!load_clipboard_from_file (dlg))
 		PostMessage (dlg, WM_COMMAND, MAKEWPARAM (IDC_CLIPEDIT_SEND, 0), 0);
-	    }
 	    return TRUE;
             
 	case IDC_CLIPEDIT_SAVE:

Modified: trunk/Src/wptClipEncryptDlg.cpp
===================================================================
--- trunk/Src/wptClipEncryptDlg.cpp	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/wptClipEncryptDlg.cpp	2006-06-28 06:59:30 UTC (rev 236)
@@ -142,6 +142,7 @@
 clip_encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {
     static listview_ctrl_t lv = NULL;
+    static int keys_sortby = 0;
     gpg_keycache_t kc;
     gpgme_key_t *rset;
     gpgme_ctx_t ctx=NULL;
@@ -176,7 +177,7 @@
 	    notify->idFrom == IDC_ENCRYPT_KEYLIST)
             PostMessage( dlg, WM_COMMAND, MAKEWPARAM( IDOK, 0 ), 0 );
 	if (notify && notify->code == LVN_COLUMNCLICK && 
-	    notify->idFrom == IDC_ENCRYPT_KEYLIST ) {
+	    notify->idFrom == IDC_ENCRYPT_KEYLIST) {
 	    NMLISTVIEW *p = (LPNMLISTVIEW) lparam;
 	    int sortby = 0;
 
@@ -187,12 +188,16 @@
 	    case  4: sortby = KEY_SORT_VALIDITY; break;
 	    default: sortby = KEY_SORT_USERID; break;
 	    }
-	    keylist_sort (lv, sortby);
+	    if ((keys_sortby & ~KEYLIST_SORT_DESC) == sortby)
+		keys_sortby ^= KEYLIST_SORT_DESC;
+	    else
+		keys_sortby = sortby;
+	    keylist_sort (lv, keys_sortby);
 	}
         return TRUE;
         
     case WM_COMMAND:
-        switch( LOWORD( wparam ) ) {
+        switch (LOWORD (wparam)) {
         case IDOK:
             rset = keylist_get_recipients (lv, &force_trust, &n);
 	    if (!n) {

Modified: trunk/Src/wptKeyEditDlgs.cpp
===================================================================
--- trunk/Src/wptKeyEditDlgs.cpp	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/wptKeyEditDlgs.cpp	2006-06-28 06:59:30 UTC (rev 236)
@@ -2073,12 +2073,38 @@
 }
 
 
+/* Create tooltip control for the listview header. */
+static HWND
+create_header_tooltip (HWND dlg)
+{
+    TOOLINFO ti;
+    HWND tt;
+
+    tt = CreateWindow (TOOLTIPS_CLASS, (LPSTR) NULL, TTS_ALWAYSTIP, 
+			CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
+			CW_USEDEFAULT, 
+			NULL, (HMENU) NULL, glob_hinst, NULL);
+    if (!tt)
+	BUG (NULL);
+    memset (&ti, 0, sizeof (ti));
+    ti.cbSize = sizeof(TOOLINFO); 
+    ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS;     
+    ti.hwnd = dlg;     
+    ti.uId = (UINT) ListView_GetHeader (GetDlgItem (dlg, IDC_KEYEDIT_KEYLIST));
+    ti.hinst = 0;
+    ti.lpszText = (char*)_("Capabilties: C = Certify, S = Sign, E = Encrypt, A = Authenticate");
+    SendMessage(tt, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
+    return tt;
+}
+
+
 /* Dialog box procedure for the edit key dialog. */
 BOOL CALLBACK
 keyedit_main_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {
     static winpt_key_t k;
     static listview_ctrl_t lvsub = NULL, lvuid = NULL;
+    static HWND tt;
     int cmd;
     HWND item;
 
@@ -2098,11 +2124,12 @@
 	if (keyedit_subkey_proc.old) {
 	    if (!SetWindowLong (item, GWL_WNDPROC, 
 				(LONG)keyedit_subkey_proc.current)) {
-		msg_box (dlg, _("Could not set subkey window procedure."), 
+		msg_box (dlg, "Could not set subkey window procedure.", 
 			 _("Key Edit"), MB_ERR);
 		BUG (NULL);
 	    }
 	}
+	tt = create_header_tooltip (dlg);
 	item = GetDlgItem (dlg, IDC_KEYEDIT_UIDLIST);
 	keyedit_uid_proc.opaque = (void*)k;
 	keyedit_uid_proc.dlg = dlg;
@@ -2111,7 +2138,7 @@
 	if (keyedit_uid_proc.old) {
 	    if (!SetWindowLong (item, GWL_WNDPROC, 
 			        (LONG)keyedit_uid_proc.current)) {
-		msg_box (dlg, _("Could not set user ID window procedure."), 
+		msg_box (dlg, "Could not set user ID window procedure.", 
 			 _("Key Edit"), MB_ERR);
 		BUG (NULL);
 	    }

Modified: trunk/Src/wptKeylist.cpp
===================================================================
--- trunk/Src/wptKeylist.cpp	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/wptKeylist.cpp	2006-06-28 06:59:30 UTC (rev 236)
@@ -622,7 +622,9 @@
 	listview_set_chkbox_style (lv);    
     ico[0] = LoadIcon (glob_hinst, (LPCTSTR)IDI_PUBKEY);
     ico[1] = LoadIcon (glob_hinst, (LPCTSTR)IDI_KEYPAIR);
-    listview_set_image_list (lv, 22, 14, ico, 2);
+    ico[2] = LoadIcon (glob_hinst, (LPCTSTR)IDI_SORT_DOWNARROW);
+    ico[3] = LoadIcon (glob_hinst, (LPCTSTR)IDI_SORT_UPARROW);
+    listview_set_image_list (lv, 22, 14, ico, 4);
     listview_del_all_items (lv);
 
     *r_lv = lv;

Modified: trunk/Src/wptListView.cpp
===================================================================
--- trunk/Src/wptListView.cpp	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/wptListView.cpp	2006-06-28 06:59:30 UTC (rev 236)
@@ -294,7 +294,7 @@
 
 
 int
-listview_sort_items( listview_ctrl_t ctx, int sortby, listview_cmp sort_cb )
+listview_sort_items (listview_ctrl_t ctx, int sortby, listview_cmp sort_cb)
 {	
     HWND hheader;
     HDITEM hdi;
@@ -330,10 +330,13 @@
     /* Set image to currently sorted field */
     memset (&hdi, 0, sizeof(hdi));
     hdi.mask = HDI_IMAGE | HDI_FORMAT;
-    Header_GetItem (hheader, idx, &hdi);
+    Header_GetItem (hheader, idx, &hdi);   
     hdi.fmt |= HDF_IMAGE | HDF_BITMAP_ON_RIGHT;
-    hdi.iImage = imagelist_getindex((sortby & KEYLIST_SORT_DESC) ? 
-				    IMI_SORT_DOWNARROW : IMI_SORT_UPARROW);
+    if (!ctx->ext_chkbox)
+	hdi.iImage = imagelist_getindex((sortby & KEYLIST_SORT_DESC) ? 
+					IMI_SORT_DOWNARROW : IMI_SORT_UPARROW);
+    else
+	hdi.iImage = (sortby & KEYLIST_SORT_DESC)? 2 : 3;
     Header_SetItem (hheader, idx, &hdi);
     return 0;
 }

Modified: trunk/Src/wptTrayPop.cpp
===================================================================
--- trunk/Src/wptTrayPop.cpp	2006-06-28 06:59:04 UTC (rev 235)
+++ trunk/Src/wptTrayPop.cpp	2006-06-28 06:59:30 UTC (rev 236)
@@ -19,13 +19,16 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
  *
  */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
 #include <windows.h>
+#include <stdio.h>
 
 #include "wptW32API.h"
+#include "wptTypes.h"
 
 #define PD_WINDOWNAME		"WinPT_TrayPop"
 #define PD_TIMER_IDENTIFIER	23
@@ -53,8 +56,14 @@
 static void 
 paint_alert (HDC *p_hdc, PAINTSTRUCT *p_ps)
 {
+    RECT recttext;
+    HFONT hOldFont;
+    HFONT hFont;
+    UINT dtFormat;
+    int text_height;
+    
     SetBkMode(*p_hdc, TRANSPARENT);
-    HFONT hFont = CreateFont(
+    hFont = CreateFont(
         13, // height of font (in css px-style)
         0, // average character width
         0, // angle of escapement
@@ -71,9 +80,8 @@
         FF_DONTCARE, // pitch and family
         "Tahoma" // typeface name
 	);
-
-    HFONT hOldFont = (HFONT) SelectObject (*p_hdc, hFont);
-    RECT recttext;
+    hOldFont = (HFONT) SelectObject (*p_hdc, hFont);
+    
     recttext.top = 0;
     recttext.bottom = PD_TRAYPOP_HEIGHT - 2;
     recttext.left = 10;
@@ -85,12 +93,12 @@
     LineTo (*p_hdc, 0, PD_TRAYPOP_HEIGHT - 3);
     LineTo (*p_hdc, 0, 0);
     
-    UINT dtFormat = DT_END_ELLIPSIS | DT_NOPREFIX | DT_WORDBREAK;
+    dtFormat = DT_END_ELLIPSIS | DT_NOPREFIX | DT_WORDBREAK;
     
     /* determine text height */
-    int text_height = DrawText (*p_hdc, store_text (NULL),
-				-1, &recttext,
-				dtFormat | DT_CENTER | DT_CALCRECT);
+    text_height = DrawText (*p_hdc, store_text (NULL),
+			    -1, &recttext,
+			    dtFormat | DT_CENTER | DT_CALCRECT);
     
     /* vertically center text in the box */
     recttext.top = PD_TRAYPOP_HEIGHT/2 - text_height/2 - 5;
@@ -173,19 +181,18 @@
 show_msg (HWND hParentWnd, int millis, LPCTSTR string)
 {    
     RECT parent;
-    int nWndWidth = PD_TRAYPOP_WIDTH;
-    int nWndHeight = PD_TRAYPOP_HEIGHT;
     MSG msg;
     HWND hWnd;
     UINT_PTR timer;
     WNDCLASS wClass;
+    int nWndWidth = PD_TRAYPOP_WIDTH;
+    int nWndHeight = PD_TRAYPOP_HEIGHT;
     
     store_text (string);
     GetWindowRect (hParentWnd, &parent);
-    
     init_wclass (&wClass, glob_hinst);
     RegisterClass (&wClass);
-    
+
     hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
 			   PD_WINDOWNAME, PD_WINDOWNAME,
 			   WS_POPUP,
@@ -193,8 +200,8 @@
 			   (parent.bottom + parent.top) / 2,
 			   nWndWidth - 2, nWndHeight - 2,
 			   NULL, NULL, glob_hinst, NULL);
-    if (hWnd == NULL)
-        return 0;
+    if (!hWnd)
+	BUG (NULL);
     else { /* Ensure parent never loses focus. */
         ShowWindow (hWnd, SW_SHOW);
         UpdateWindow (hWnd);



More information about the Winpt-commits mailing list