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

Annotation of /trunk/src/OEDlgViewer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (hide annotations)
Sun Jun 4 10:12:47 2006 UTC (18 years, 11 months ago) by twoaday
File MIME type: text/plain
File size: 2587 byte(s)
Prepare new release.


1 twoaday 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 twoaday 11 n = GetDlgItemText (dlg, IDC_VIEWER_TEXT2, p, n);
44 twoaday 1 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 twoaday 12 char *p, *out;
54 twoaday 1
55     switch (msg) {
56     case WM_INITDIALOG:
57     viewer = (viewer_ctx_t)lparam;
58     assert (viewer);
59 twoaday 12 SetDlgItemText (dlg, IDC_VIEWER_COPY, _("&Copy"));
60     SetDlgItemText (dlg, IDC_VIEWER_QUOTE, _("&Quote"));
61     SetDlgItemText (dlg, IDOK, _("&OK"));
62 twoaday 1 SetWindowText (dlg, _("Message Viewer"));
63 twoaday 11 SetDlgItemText (dlg, IDC_VIEWER_TEXT2, viewer->msg);
64 twoaday 1 SetForegroundWindow (dlg);
65     SetFocus (GetDlgItem (dlg, IDOK));
66 twoaday 16 center_window (dlg, viewer->main_wnd);
67 twoaday 1 return FALSE;
68    
69     case WM_COMMAND:
70     switch (LOWORD (wparam)) {
71 twoaday 19 case IDCANCEL:
72     EndDialog (dlg, 0);
73     return TRUE;
74    
75 twoaday 1 case IDOK:
76     EndDialog (dlg, 0);
77     return TRUE;
78    
79     case IDC_VIEWER_QUOTE:
80 twoaday 11 p = get_item_text (dlg, IDC_VIEWER_TEXT2);
81 twoaday 12 if (!p)
82     return TRUE;
83     quote_msg_text (p, &out);
84     SetDlgItemText (dlg, IDC_VIEWER_TEXT2, out);
85 twoaday 1 free_if_alloc (p);
86 twoaday 12 free_if_alloc (out);
87 twoaday 1 return TRUE;
88    
89     case IDC_VIEWER_COPY:
90 twoaday 11 p = get_item_text (dlg, IDC_VIEWER_TEXT2);
91 twoaday 1 if (p != NULL)
92     set_clip_text (NULL, p, strlen (p));
93     free_if_alloc (p);
94     return TRUE;
95     }
96     break;
97     }
98     return FALSE;
99     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26