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

Annotation of /trunk/Src/wptFileSaveDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (hide annotations)
Mon Oct 31 21:14:11 2005 UTC (19 years, 4 months ago) by werner
File size: 4004 byte(s)
More changes.  Compiles again but there are at least gettext issues with
w32-gettext.c.  I can't get a gpg-error build with ENABLE_NLS.

1 werner 36 /* wptFileSaveDlg.cpp - Save a file
2     * Copyright (C) 2002, 2003 Timo Schulz
3     *
4     * This file is part of WinPT.
5     *
6     * WinPT is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * WinPT 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 General Public License
17     * along with WinPT; 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    
25     #include <windows.h>
26    
27 werner 47 #include "resource.h"
28 werner 36 #include "wptTypes.h"
29     #include "wptNLS.h"
30     #include "wptGPG.h"
31     #include "wptW32API.h"
32     #include "wptErrors.h"
33    
34     static void
35     switch_buttons( HWND dlg, int file )
36     {
37     int check1 = file? BST_CHECKED : BST_UNCHECKED;
38     int check2 = file? BST_UNCHECKED: BST_CHECKED;
39    
40     CheckDlgButton( dlg, IDC_FILE_SAVE_TOFILE, check1 );
41     CheckDlgButton( dlg, IDC_FILE_SAVE_CLIP, check2 );
42     } /* switch_buttons */
43    
44    
45     BOOL CALLBACK
46     file_save_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
47     {
48     gpgme_data_t sig, plain;
49     gpgme_error_t err;
50     const char *filename;
51     int has_data;
52     char file[768];
53    
54     switch ( msg ) {
55     case WM_INITDIALOG:
56     #ifndef LANG_DE
57     SetWindowText( dlg, _("Save Plaintext") );
58     #endif
59     switch_buttons( dlg, 0 );
60     SetForegroundWindow( dlg );
61     return TRUE;
62    
63     case WM_SYSCOMMAND:
64     if( LOWORD( wparam ) == SC_CLOSE )
65     EndDialog( dlg, TRUE );
66     return FALSE;
67    
68     case WM_COMMAND:
69     switch ( LOWORD(wparam) ) {
70     case IDC_FILE_SAVE_SELECT:
71     filename = get_filesave_dlg( dlg, _("Destination for Plaintext"), NULL, NULL );
72     if( filename ) {
73     SetDlgItemText( dlg, IDC_FILE_SAVE_FILE, filename );
74     switch_buttons( dlg, 1 );
75     }
76     return TRUE;
77    
78     case IDOK:
79     if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_TOFILE ) ) {
80     if( !GetDlgItemText( dlg, IDC_FILE_SAVE_FILE, file, sizeof file - 1 ) ) {
81     msg_box( dlg, _("Please enter a filename."), _("Save Plaintext"), MB_INFO );
82     return FALSE;
83     }
84     err = gpg_data_new_from_clipboard (&sig, 0);
85     if( err ) {
86     msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );
87     return FALSE;
88     }
89     gpg_data_extract_plaintext( sig, &plain );
90     gpg_data_release_and_set_file( plain, file );
91     gpgme_data_release( sig );
92     msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );
93     }
94     else if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_CLIP ) ) {
95     if( !gpg_clip_istext_avail( &has_data ) && !has_data ) {
96     msg_box( dlg, winpt_strerror( WPTERR_CLIP_ISEMPTY ), _("Save Plaintext"), MB_ERR );
97     return FALSE;
98     }
99     err = gpg_data_new_from_clipboard (&sig, 0);
100     if( err ) {
101     msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );
102     return FALSE;
103     }
104     gpg_data_extract_plaintext( sig, &plain );
105     gpg_data_release_and_set_clipboard( plain, 0 );
106     gpgme_data_release( sig );
107     msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );
108     }
109     EndDialog( dlg, TRUE );
110     return TRUE;
111    
112     case IDCANCEL:
113     EndDialog( dlg, FALSE );
114     return FALSE;
115     }
116     break;
117     }
118    
119     return FALSE;
120 twoaday 2 } /* file_save_dlg_proc */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26