/[winpt]/trunk/Src/wptSigTreeDlg.cpp
ViewVC logotype

Diff of /trunk/Src/wptSigTreeDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 176 by twoaday, Mon Feb 13 09:38:03 2006 UTC revision 193 by twoaday, Sat Apr 1 12:36:35 2006 UTC
# Line 28  Line 28 
28  #include "wptTypes.h"  #include "wptTypes.h"
29  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
30  #include "wptContext.h"  #include "wptContext.h"
31    #include "wptUTF8.h"
32    #include "wptW32API.h"
33    
34    
35    /* ID to display signature properties. */
36    #define _ID_SIGCTX_PROPS 65000
37    
38    
39  BOOL CALLBACK sigprops_dlg_proc (HWND dlg, UINT msg,  BOOL CALLBACK sigprops_dlg_proc (HWND dlg, UINT msg,
40                                   WPARAM wparam, LPARAM lparam);                                   WPARAM wparam, LPARAM lparam);
41  BOOL CALLBACK  BOOL CALLBACK keysig_dlg_proc (HWND dlg, UINT msg,
42  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam);                                 WPARAM wparam, LPARAM lparam);
43    
44  /* Initialize the signature tree based on the given key @key. */  /* Initialize the signature tree based on the given key @key. */
45  static void  static void
# Line 44  sigtree_load (HWND dlg, gpgme_key_t key) Line 51  sigtree_load (HWND dlg, gpgme_key_t key)
51      gpgme_user_id_t u;      gpgme_user_id_t u;
52      gpgme_key_sig_t s;      gpgme_key_sig_t s;
53      gpgme_key_t signer;      gpgme_key_t signer;
54        char *p;
55    
56      memset (&tvi, 0, sizeof (tvi));      memset (&tvi, 0, sizeof (tvi));
57      memset (&ctx, 0, sizeof (ctx));      memset (&ctx, 0, sizeof (ctx));
58      for (u=key->uids; u; u = u->next) {      for (u=key->uids; u; u = u->next) {
59          if (u->revoked)          if (u->revoked)
60              continue;              continue;
61          tvi.pszText = u->uid;          p = utf8_to_native (u->uid);
62            tvi.pszText = p;
63          tvi.state = TVIS_BOLD;          tvi.state = TVIS_BOLD;
64          tvi.mask = TVIF_TEXT;          tvi.mask = TVIF_TEXT;
65          tvi.iImage = 0;          tvi.iImage = 0;
# Line 58  sigtree_load (HWND dlg, gpgme_key_t key) Line 67  sigtree_load (HWND dlg, gpgme_key_t key)
67          ctx.hParent = TVI_ROOT;          ctx.hParent = TVI_ROOT;
68          ctx.item = tvi;          ctx.item = tvi;
69          uid = TreeView_InsertItem (dlg, &ctx);          uid = TreeView_InsertItem (dlg, &ctx);
70            safe_free (p);
71          for (s = u->signatures; s; s=s->next) {          for (s = u->signatures; s; s=s->next) {
72              if (get_pubkey (s->keyid+8, &signer))              if (get_pubkey (s->keyid+8, &signer))
73                  continue;                  continue;
74              tvi.pszText = signer->uids->uid;              p = utf8_to_native (signer->uids->uid);
75                tvi.pszText = p;
76              tvi.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;              tvi.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
77              tvi.iImage = 1;              tvi.iImage = 1;
78              tvi.iSelectedImage = 1;              tvi.iSelectedImage = 1;
# Line 69  sigtree_load (HWND dlg, gpgme_key_t key) Line 80  sigtree_load (HWND dlg, gpgme_key_t key)
80              ctx.hParent = uid;              ctx.hParent = uid;
81              ctx.item = tvi;              ctx.item = tvi;
82              TreeView_InsertItem (dlg, &ctx);              TreeView_InsertItem (dlg, &ctx);
83                safe_free (p);
84          }          }
85      }      }
86  }  }
# Line 91  treeview_set_image_list (HWND tree, HICO Line 103  treeview_set_image_list (HWND tree, HICO
103  }  }
104    
105    
106    static void
107    create_popup (HWND dlg)
108    {
109        HMENU hm;
110        POINT p;
111    
112        hm = CreatePopupMenu ();
113        if (!hm)
114            BUG (0);
115        insert_menu_item (hm, 0, _ID_SIGCTX_PROPS, _("Signature &Properties"));
116        GetCursorPos (&p);
117        TrackPopupMenu (hm, 0, p.x, p.y, 0, dlg, NULL);
118        DestroyMenu (hm);
119    }
120    
121    
122    static void
123    show_sigprops (HWND dlg)
124    {
125        HWND tree;
126        HTREEITEM hti;
127        TVITEM tvi;
128    
129        memset (&tvi, 0, sizeof (tvi));
130        tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);
131        hti = TreeView_GetSelection (tree);
132        tvi.mask = TVIF_PARAM;
133        tvi.hItem = hti;
134        TreeView_GetItem (tree, &tvi);
135        if (tvi.lParam != 0)
136            DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
137            sigprops_dlg_proc, tvi.lParam);
138    }
139    
140    
141  /* Dialog box procedure for the tree based signature listing. */  /* Dialog box procedure for the tree based signature listing. */
142  BOOL CALLBACK  BOOL CALLBACK
143  sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sigtree_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
# Line 98  sigtree_dlg_proc (HWND dlg, UINT msg, WP Line 145  sigtree_dlg_proc (HWND dlg, UINT msg, WP
145      static winpt_key_t key;      static winpt_key_t key;
146      static HWND tree;      static HWND tree;
147      static HIMAGELIST hil;      static HIMAGELIST hil;
       
148      HICON ico[2];      HICON ico[2];
149      NMHDR *nft;      NMHDR *nft;
150      char inf[256];      char inf[300], *p;
151    
152      switch (msg) {      switch (msg) {
153      case WM_INITDIALOG:      case WM_INITDIALOG:
# Line 113  sigtree_dlg_proc (HWND dlg, UINT msg, WP Line 159  sigtree_dlg_proc (HWND dlg, UINT msg, WP
159          tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);          tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);
160          hil = treeview_set_image_list (tree, ico, 2);          hil = treeview_set_image_list (tree, ico, 2);
161          sigtree_load (tree, key->ctx);          sigtree_load (tree, key->ctx);
162          _snprintf (inf, sizeof (inf)-1, _("Signature Tree for \"%s\""),          p = utf8_to_native (key->ctx->uids->name);
163                     key->ctx->uids->uid);          _snprintf (inf, sizeof (inf)-1,
164                       _("Signature Tree for \"%s\" (0x%s)"),
165                       p, key->ctx->subkeys->keyid+8);
166            safe_free (p);
167            SetDlgItemText (dlg, IDC_VKEYSIG_EDIT, _("Edit..."));
168          SetWindowText (dlg, inf);          SetWindowText (dlg, inf);
169          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
170          break;          break;
# Line 125  sigtree_dlg_proc (HWND dlg, UINT msg, WP Line 175  sigtree_dlg_proc (HWND dlg, UINT msg, WP
175    
176      case WM_NOTIFY:      case WM_NOTIFY:
177          nft = (NMHDR*)lparam;          nft = (NMHDR*)lparam;
178          if (nft->code == NM_DBLCLK) {          if (nft->code == NM_DBLCLK)
179              HTREEITEM hti;              show_sigprops (dlg);
180              TVITEM tvi;          else if (nft->code == NM_RCLICK)
181                create_popup (dlg);
             memset (&tvi, 0, sizeof (tvi));  
             tree = GetDlgItem (dlg, IDC_VKEYSIG_TREE);  
             hti = TreeView_GetSelection (tree);  
             tvi.mask = TVIF_PARAM;  
             tvi.hItem = hti;  
             TreeView_GetItem (tree, &tvi);  
             if (tvi.lParam != 0)  
                 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,  
                                 sigprops_dlg_proc, tvi.lParam);  
         }  
182          break;          break;
183    
184      case WM_COMMAND:      case WM_COMMAND:
185          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
186            case _ID_SIGCTX_PROPS:
187                show_sigprops (dlg);
188                break;
189    
190          case IDOK:          case IDOK:
191              EndDialog (dlg, 1);              EndDialog (dlg, 1);
192              break;              break;

Legend:
Removed from v.176  
changed lines
  Added in v.193

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26