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

Contents of /trunk/src/OEDlgViewer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (show annotations)
Tue Apr 11 06:56:23 2006 UTC (19 years ago) by twoaday
File MIME type: text/plain
File size: 2627 byte(s)


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 * You should have received a copy of the GNU Lesser General Public License
17 * along with GPGOE; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 #include <windows.h>
25 #include <assert.h>
26 #include "resource.h"
27 #include "gpgme.h"
28 #include "GPGOE.h"
29
30
31 /* Read all text from the dialog item @id and
32 return it as a string. */
33 char*
34 get_item_text (HWND dlg, int id)
35 {
36 char *p;
37 int n;
38
39 n = SendDlgItemMessage (dlg, id, WM_GETTEXTLENGTH, 0, 0);
40 if (n < 1)
41 return NULL;
42 p = xcalloc (1, n+1);
43 n = GetDlgItemText (dlg, IDC_VIEWER_TEXT2, p, n);
44 return p;
45 }
46
47
48 /* Text viewer dialog box procedure. */
49 BOOL CALLBACK
50 viewer_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
51 {
52 static viewer_ctx_t viewer;
53 char *p, *out;
54
55 switch (msg) {
56 case WM_INITDIALOG:
57 viewer = (viewer_ctx_t)lparam;
58 assert (viewer);
59 SetDlgItemText (dlg, IDC_VIEWER_COPY, _("&Copy"));
60 SetDlgItemText (dlg, IDC_VIEWER_QUOTE, _("&Quote"));
61 SetDlgItemText (dlg, IDOK, _("&OK"));
62 SetWindowText (dlg, _("Message Viewer"));
63 SetDlgItemText (dlg, IDC_VIEWER_TEXT2, viewer->msg);
64 SetForegroundWindow (dlg);
65 SetFocus (GetDlgItem (dlg, IDOK));
66 center_window (dlg, viewer->main_wnd);
67 return FALSE;
68
69 case WM_SYSCOMMAND:
70 if (LOWORD (wparam) == SC_CLOSE)
71 EndDialog (dlg, 0);
72 return FALSE;
73
74 case WM_COMMAND:
75 switch (LOWORD (wparam)) {
76 case IDOK:
77 EndDialog (dlg, 0);
78 return TRUE;
79
80 case IDC_VIEWER_QUOTE:
81 p = get_item_text (dlg, IDC_VIEWER_TEXT2);
82 if (!p)
83 return TRUE;
84 quote_msg_text (p, &out);
85 SetDlgItemText (dlg, IDC_VIEWER_TEXT2, out);
86 free_if_alloc (p);
87 free_if_alloc (out);
88 return TRUE;
89
90 case IDC_VIEWER_COPY:
91 p = get_item_text (dlg, IDC_VIEWER_TEXT2);
92 if (p != NULL)
93 set_clip_text (NULL, p, strlen (p));
94 free_if_alloc (p);
95 return TRUE;
96 }
97 break;
98 }
99 return FALSE;
100 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26