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

Diff of /trunk/Src/wptClipEditDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 36 by werner, Thu Oct 27 15:25:13 2005 UTC revision 105 by twoaday, Wed Nov 30 10:22:00 2005 UTC
# Line 17  Line 17 
17   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
   
20  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
21  #include <config.h>  #include <config.h>
22  #endif  #endif
23    
24  #include <windows.h>  #include <windows.h>
 #include <windows.h>  
25  #include <stdio.h>  #include <stdio.h>
26    
27  #include "wptTypes.h"  #include "wptTypes.h"
# Line 32  Line 30 
30  #include "wptErrors.h"  #include "wptErrors.h"
31  #include "wptGPG.h"  #include "wptGPG.h"
32  #include "wptNLS.h"  #include "wptNLS.h"
33  #include "../resource.h"  #include "resource.h"
34    
35    
36  /* Load the clipboard contents into the text field in @dlg.  /* Load the clipboard contents into the text field in @dlg.
# Line 99  load_clipboard_from_file (HWND dlg) Line 97  load_clipboard_from_file (HWND dlg)
97      if (GetOpenFileName (&open)) {      if (GetOpenFileName (&open)) {
98          if( (size=get_file_size (file)) > MAX_CLIPTEXT_SIZE) {                if( (size=get_file_size (file)) > MAX_CLIPTEXT_SIZE) {      
99              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"
100                                   "Still proceed?"), _("Clipboard"), MB_INFO|MB_YESNO);                                         "Still proceed?"), _("Clipboard"),
101              if (id == IDNO)                                MB_INFO|MB_YESNO);
102                if (id == IDNO)
103                  return -1;                  return -1;
104          }          }
105          fp = fopen (file, "rb");          fp = fopen (file, "rb");
106          if (!fp) {          if (!fp) {
107              msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN), _("Clipboard"), MB_ERR);              msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN),
108                         _("Clipboard"), MB_ERR);
109              return FALSE;              return FALSE;
110          }          }
111          p = new char[size+1];          p = new char[size+1];
# Line 127  save_clipboard_to_file (HWND dlg) Line 127  save_clipboard_to_file (HWND dlg)
127  {  {
128      OPENFILENAME save;      OPENFILENAME save;
129      FILE *fp;      FILE *fp;
130      char *p;      char *p=NULL;
131      char file[300] = "";      char file[300] = "";
132      DWORD nbytes;      DWORD nbytes;
133      int id;      int id;
# Line 152  save_clipboard_to_file (HWND dlg) Line 152  save_clipboard_to_file (HWND dlg)
152          }          }
153          fp = fopen (file, "wb");          fp = fopen (file, "wb");
154          if (!fp) {          if (!fp) {
155              msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT), _("Clipboard"), MB_ERR);              msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT),
156                         _("Clipboard"), MB_ERR);
157              return FALSE;              return FALSE;
158          }          }
159          /* XXX: there is a NUL-byte at the end. */          /* XXX: there is a NUL-byte at the end. */
160          nbytes = SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, WM_GETTEXTLENGTH, 0, 0);          nbytes = SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2,
161                                         WM_GETTEXTLENGTH, 0, 0);
162          if (nbytes > 0) {          if (nbytes > 0) {
163              p = new char[nbytes+1];              p = new char[nbytes+1];
164              if (!p)              if (!p)
165                  BUG (NULL);                  BUG (NULL);
166              GetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p, nbytes);              GetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p, nbytes);
167              fwrite (p, 1, nbytes, fp);              fwrite (p, 1, nbytes, fp);
168                
169          }                    }          
170          fclose (fp);          fclose (fp);
171          free_if_alloc (p);          free_if_alloc (p);
# Line 182  clip_edit_dlg_proc (HWND dlg, UINT msg, Line 185  clip_edit_dlg_proc (HWND dlg, UINT msg,
185          SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r"));          SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r"));
186          SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load"));              SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load"));    
187          SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save"));          SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save"));
188            SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes"));
189            SetDlgItemText (dlg, IDOK, _("&Exit"));
190    
191          load_clipboard (dlg);          load_clipboard (dlg);
192          center_window (dlg, NULL);          center_window (dlg, NULL);
# Line 229  clip_edit_dlg_proc (HWND dlg, UINT msg, Line 234  clip_edit_dlg_proc (HWND dlg, UINT msg,
234          case IDC_CLIPEDIT_LOAD:          case IDC_CLIPEDIT_LOAD:
235              if (!load_clipboard_from_file (dlg)) {              if (!load_clipboard_from_file (dlg)) {
236                  /* XXX: for some files the code produces a crash! */                  /* XXX: for some files the code produces a crash! */
237                  PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), NULL);                  PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), 0);
238              }              }
239              return TRUE;              return TRUE;
240                            
# Line 242  clip_edit_dlg_proc (HWND dlg, UINT msg, Line 247  clip_edit_dlg_proc (HWND dlg, UINT msg,
247            
248      return FALSE;      return FALSE;
249  }  }
   

Legend:
Removed from v.36  
changed lines
  Added in v.105

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26