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

Annotation of /trunk/Src/wptFileSaveDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (hide annotations)
Mon Oct 31 14:04:59 2005 UTC (19 years, 4 months ago) by werner
File size: 4025 byte(s)
Minor changes; compiles now but gettext is still missing.

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     #include <windows.h>
27    
28 werner 47 #include "resource.h"
29 werner 36 #include "wptTypes.h"
30     #include "wptNLS.h"
31     #include "wptGPG.h"
32     #include "wptW32API.h"
33     #include "wptErrors.h"
34    
35     static void
36     switch_buttons( HWND dlg, int file )
37     {
38     int check1 = file? BST_CHECKED : BST_UNCHECKED;
39     int check2 = file? BST_UNCHECKED: BST_CHECKED;
40    
41     CheckDlgButton( dlg, IDC_FILE_SAVE_TOFILE, check1 );
42     CheckDlgButton( dlg, IDC_FILE_SAVE_CLIP, check2 );
43     } /* switch_buttons */
44    
45    
46     BOOL CALLBACK
47     file_save_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )
48     {
49     gpgme_data_t sig, plain;
50     gpgme_error_t err;
51     const char *filename;
52     int has_data;
53     char file[768];
54    
55     switch ( msg ) {
56     case WM_INITDIALOG:
57     #ifndef LANG_DE
58     SetWindowText( dlg, _("Save Plaintext") );
59     #endif
60     switch_buttons( dlg, 0 );
61     SetForegroundWindow( dlg );
62     return TRUE;
63    
64     case WM_SYSCOMMAND:
65     if( LOWORD( wparam ) == SC_CLOSE )
66     EndDialog( dlg, TRUE );
67     return FALSE;
68    
69     case WM_COMMAND:
70     switch ( LOWORD(wparam) ) {
71     case IDC_FILE_SAVE_SELECT:
72     filename = get_filesave_dlg( dlg, _("Destination for Plaintext"), NULL, NULL );
73     if( filename ) {
74     SetDlgItemText( dlg, IDC_FILE_SAVE_FILE, filename );
75     switch_buttons( dlg, 1 );
76     }
77     return TRUE;
78    
79     case IDOK:
80     if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_TOFILE ) ) {
81     if( !GetDlgItemText( dlg, IDC_FILE_SAVE_FILE, file, sizeof file - 1 ) ) {
82     msg_box( dlg, _("Please enter a filename."), _("Save Plaintext"), MB_INFO );
83     return FALSE;
84     }
85     err = gpg_data_new_from_clipboard (&sig, 0);
86     if( err ) {
87     msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );
88     return FALSE;
89     }
90     gpg_data_extract_plaintext( sig, &plain );
91     gpg_data_release_and_set_file( plain, file );
92     gpgme_data_release( sig );
93     msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );
94     }
95     else if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_CLIP ) ) {
96     if( !gpg_clip_istext_avail( &has_data ) && !has_data ) {
97     msg_box( dlg, winpt_strerror( WPTERR_CLIP_ISEMPTY ), _("Save Plaintext"), MB_ERR );
98     return FALSE;
99     }
100     err = gpg_data_new_from_clipboard (&sig, 0);
101     if( err ) {
102     msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );
103     return FALSE;
104     }
105     gpg_data_extract_plaintext( sig, &plain );
106     gpg_data_release_and_set_clipboard( plain, 0 );
107     gpgme_data_release( sig );
108     msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );
109     }
110     EndDialog( dlg, TRUE );
111     return TRUE;
112    
113     case IDCANCEL:
114     EndDialog( dlg, FALSE );
115     return FALSE;
116     }
117     break;
118     }
119    
120     return FALSE;
121 twoaday 2 } /* file_save_dlg_proc */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26