1 |
/* wptClipEditDlg.cpp - Clipboard Editor dialog |
/* wptClipEditDlg.cpp - Clipboard Editor dialog |
2 |
* Copyright (C) 2000-2004 Timo Schulz |
* Copyright (C) 2000-2005 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
30 |
#include "../resource.h" |
#include "../resource.h" |
31 |
|
|
32 |
|
|
33 |
|
/* Dialog box procedure for the clipboard editor. */ |
34 |
BOOL CALLBACK |
BOOL CALLBACK |
35 |
clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
36 |
{ |
{ |
57 |
} |
} |
58 |
clipmem = GetClipboardData (CF_TEXT); |
clipmem = GetClipboardData (CF_TEXT); |
59 |
if (clipmem == NULL) { |
if (clipmem == NULL) { |
60 |
center_window (dlg); |
center_window (dlg, NULL); |
61 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
62 |
CloseClipboard (); |
CloseClipboard (); |
63 |
return FALSE; |
return FALSE; |
75 |
CloseClipboard (); |
CloseClipboard (); |
76 |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
77 |
free_if_alloc (p); |
free_if_alloc (p); |
78 |
center_window (dlg); |
center_window (dlg, NULL); |
79 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
80 |
return TRUE; |
return TRUE; |
81 |
|
|
93 |
case IDC_CLIPEDIT_SEND: |
case IDC_CLIPEDIT_SEND: |
94 |
if (IsDlgButtonChecked (dlg, IDC_CLIPEDIT_QUOTE)) { |
if (IsDlgButtonChecked (dlg, IDC_CLIPEDIT_QUOTE)) { |
95 |
gpgme_data_t txt; |
gpgme_data_t txt; |
96 |
gpgme_data_new_from_clipboard (&txt); |
gpg_data_new_from_clipboard (&txt, 0); |
97 |
gpgme_data_mail_quote (&txt); |
gpg_data_mail_quote (&txt); |
98 |
gpgme_data_release_and_set_clipboard (txt); |
gpg_data_release_and_set_clipboard (txt, 0); |
99 |
SendMessage (dlg, WM_INITDIALOG, 0, 0); |
SendMessage (dlg, WM_INITDIALOG, 0, 0); |
100 |
return TRUE; |
return TRUE; |
101 |
} |
} |
104 |
return TRUE; |
return TRUE; |
105 |
|
|
106 |
case IDC_CLIPEDIT_CLEAR: |
case IDC_CLIPEDIT_CLEAR: |
107 |
if( OpenClipboard( NULL ) == FALSE ) { |
if (OpenClipboard (NULL) == FALSE) { |
108 |
msg_box( dlg, winpt_strerror( WPTERR_CLIP_OPEN ), _("Clipboard"), MB_ERR ); |
msg_box (dlg, winpt_strerror (WPTERR_CLIP_OPEN), _("Clipboard"), MB_ERR); |
109 |
return FALSE; |
return FALSE; |
110 |
} |
} |
111 |
if (EmptyClipboard () == FALSE) { |
if (EmptyClipboard () == FALSE) { |
122 |
open.lStructSize = sizeof (OPENFILENAME); |
open.lStructSize = sizeof (OPENFILENAME); |
123 |
open.hInstance = glob_hinst; |
open.hInstance = glob_hinst; |
124 |
open.lpstrTitle = _("File Open"); |
open.lpstrTitle = _("File Open"); |
125 |
open.lpstrFilter = (char *)_("All Files (*.*)\0*.*"); |
open.lpstrFilter = (char *)_("All Files (*.*)\0*.*\0\0"); |
126 |
open.hwndOwner = dlg; |
open.hwndOwner = dlg; |
127 |
open.lpstrFile = file; |
open.lpstrFile = file; |
128 |
open.nMaxFile = sizeof (file)-1; |
open.nMaxFile = sizeof (file)-1; |
129 |
open.Flags = 0; |
open.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST; |
130 |
if (GetOpenFileName (&open)) { |
if (GetOpenFileName (&open)) { |
131 |
if( (size=get_file_size( file )) > MAX_CLIPTEXT_SIZE ) { |
if( (size=get_file_size (file)) > MAX_CLIPTEXT_SIZE) { |
132 |
id = msg_box( dlg, _("The file you want to add is very large.\n" |
id = msg_box (dlg, _("The file you want to add is very large.\n" |
133 |
"Still proceed?"), _("Clipboard"), MB_INFO|MB_YESNO ); |
"Still proceed?"), _("Clipboard"), MB_INFO|MB_YESNO); |
134 |
if( id == IDNO ) |
if (id == IDNO) |
135 |
return FALSE; |
return FALSE; |
136 |
} |
} |
137 |
fp = fopen( file, "rb" ); |
fp = fopen (file, "rb"); |
138 |
if (!fp) { |
if (!fp) { |
139 |
msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN), _("Clipboard"), MB_ERR); |
msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN), _("Clipboard"), MB_ERR); |
140 |
return FALSE; |
return FALSE; |
142 |
p = new char[size+1]; |
p = new char[size+1]; |
143 |
if (!p) |
if (!p) |
144 |
BUG (0); |
BUG (0); |
145 |
fread( p, 1, size, fp ); |
fread (p, 1, size, fp); |
146 |
p[size] = '\0'; |
p[size] = '\0'; |
147 |
fclose( fp ); |
fclose (fp); |
148 |
SetDlgItemText( dlg, IDC_CLIPEDIT_CLIPTEXT2, p ); |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
149 |
free_if_alloc( p ); |
free_if_alloc (p); |
150 |
PostMessage( dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), NULL ); |
/* XXX: for some files the code produces a crash! */ |
151 |
|
PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), NULL); |
152 |
return TRUE; |
return TRUE; |
153 |
} |
} |
154 |
break; |
break; |
155 |
|
|
156 |
case IDC_CLIPEDIT_SAVE: |
case IDC_CLIPEDIT_SAVE: |
157 |
memset (&open, 0, sizeof (open)); |
memset (&open, 0, sizeof (open)); |
158 |
open.lStructSize = sizeof OPENFILENAME; |
open.lStructSize = sizeof (OPENFILENAME); |
159 |
open.hInstance = glob_hinst; |
open.hInstance = glob_hinst; |
160 |
open.lpstrTitle = _("File Save"); |
open.lpstrTitle = _("File Save"); |
161 |
open.lpstrFile = (char *)_("All Files (*.*)\0*.*"); |
open.lpstrFile = (char *)_("All Files (*.*)\0*.*\0\0"); |
162 |
open.hwndOwner = dlg; |
open.hwndOwner = dlg; |
163 |
open.lpstrFile = file; |
open.lpstrFile = file; |
164 |
open.nMaxFile = sizeof (file) - 1; |
open.nMaxFile = sizeof (file) - 1; |
165 |
|
open.Flags = OFN_OVERWRITEPROMPT; |
166 |
|
|
167 |
if( GetSaveFileName( &open ) ) { |
if( GetSaveFileName( &open ) ) { |
168 |
if( file_exist_check( file ) == 0 ) { |
if( file_exist_check( file ) == 0 ) { |
169 |
id = msg_box( dlg, _("File already exists!\nOverwrite?"), |
id = log_box (_("Clipboard"), MB_YESNO, |
170 |
_("Clipboard"), MB_INFO|MB_YESNO ); |
_("\"%s\" already exists.\n" |
171 |
|
"Replace existing file?"), file); |
172 |
if( id == IDNO ) |
if( id == IDNO ) |
173 |
return FALSE; |
return FALSE; |
174 |
} |
} |
194 |
} |
} |
195 |
|
|
196 |
return FALSE; |
return FALSE; |
197 |
} /* clip_edit_dlg_proc */ |
} |
198 |
|
|