/[gpgoe]/trunk/src/OEDlgViewer.c
ViewVC logotype

Contents of /trunk/src/OEDlgViewer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (show annotations)
Tue Dec 13 10:40:30 2011 UTC (13 years, 4 months ago) by twoaday
File MIME type: text/plain
File size: 2374 byte(s)
Commit code for backup purposes.


1 /* OEDlgViewer.c - OE text viewer
2 * Copyright (C) 2001, 2002, 2003, 2006 Timo Schulz
3 *
4 * This file is part of GPGOE.
5 *
6 * GPGOE is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * GPGOE is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17 #ifdef HAVE_CONFIG_H
18 #include <config.h>
19 #endif
20 #include <windows.h>
21 #include <assert.h>
22 #include "resource.h"
23 #include "gpgme.h"
24 #include "GPGOE.h"
25
26
27 /* Read all text from the dialog item @id and
28 return it as a string. */
29 char*
30 get_item_text (HWND dlg, int id)
31 {
32 char *p;
33 int n;
34
35 n = SendDlgItemMessage (dlg, id, WM_GETTEXTLENGTH, 0, 0);
36 if (n < 1)
37 return NULL;
38 p = xcalloc (1, n+1);
39 n = GetDlgItemText (dlg, IDC_VIEWER_TEXT2, p, n);
40 return p;
41 }
42
43
44 /* Text viewer dialog box procedure. */
45 BOOL CALLBACK
46 viewer_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
47 {
48 static viewer_ctx_t viewer;
49 char *p, *out;
50
51 switch (msg) {
52 case WM_INITDIALOG:
53 viewer = (viewer_ctx_t)lparam;
54 assert (viewer);
55 SetDlgItemText (dlg, IDC_VIEWER_COPY, _("&Copy"));
56 SetDlgItemText (dlg, IDC_VIEWER_QUOTE, _("&Quote"));
57 SetDlgItemText (dlg, IDOK, _("&OK"));
58 SetWindowText (dlg, _("Message Viewer"));
59 SetDlgItemText (dlg, IDC_VIEWER_TEXT2, viewer->msg);
60 SetForegroundWindow (dlg);
61 SetFocus (GetDlgItem (dlg, IDOK));
62 center_window (dlg, viewer->main_wnd);
63 return FALSE;
64
65 case WM_COMMAND:
66 switch (LOWORD (wparam)) {
67 case IDCANCEL:
68 EndDialog (dlg, 0);
69 return TRUE;
70
71 case IDOK:
72 EndDialog (dlg, 0);
73 return TRUE;
74
75 case IDC_VIEWER_QUOTE:
76 p = get_item_text (dlg, IDC_VIEWER_TEXT2);
77 if (!p)
78 return TRUE;
79 quote_msg_text (p, &out);
80 SetDlgItemText (dlg, IDC_VIEWER_TEXT2, out);
81 free_if_alloc (p);
82 free_if_alloc (out);
83 return TRUE;
84
85 case IDC_VIEWER_COPY:
86 p = get_item_text (dlg, IDC_VIEWER_TEXT2);
87 if (p != NULL)
88 set_clip_text (NULL, p, strlen (p));
89 free_if_alloc (p);
90 return TRUE;
91 }
92 break;
93 }
94 return FALSE;
95 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26