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

Annotation of /trunk/Src/wptCommonDlg.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: 3373 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 /* wptCommonDlg.cpp
2     * Copyright (C) 2004, 2005 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
29     #include "wptTypes.h"
30     #include "wptW32API.h"
31     #include "wptVersion.h"
32     #include "wptGPG.h"
33     #include "wptCommonCtl.h"
34     #include "wptContext.h"
35    
36    
37     /* check if the given buf contains a valid URL. */
38     static int
39     check_URL (const char *buf)
40     {
41     /* XXX: be more strict */
42     if (!strchr (buf, ':'))
43     return -1;
44     if (!strstr (buf, "//"))
45     return -1;
46     return 0;
47     }
48    
49    
50     static BOOL CALLBACK
51     http_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
52     {
53     static struct URL_ctx_s * ctx;
54     int n;
55    
56     switch (msg) {
57     case WM_INITDIALOG:
58     ctx = (struct URL_ctx_s*)lparam;
59     if (!ctx)
60     BUG (0);
61     if (ctx->desc != NULL)
62     SetWindowText (dlg, ctx->desc);
63     if (ctx->title != NULL)
64     SetDlgItemText (dlg, IDC_HTTP_TITLE, ctx->title);
65     SetForegroundWindow (dlg);
66     break;
67    
68     case WM_COMMAND:
69     switch (LOWORD (wparam)) {
70     case IDOK:
71     n = GetDlgItemText (dlg, IDC_HTTP_URL, ctx->url, DIM (ctx->url)-1);
72     if (ctx->check && (!n || check_URL (ctx->url))) {
73     msg_box (dlg, _("Please enter a valid URL."), "HTTP", MB_ERR);
74     return FALSE;
75     }
76     ctx->cancel = 0;
77     EndDialog (dlg, TRUE);
78     break;
79    
80     case IDCANCEL:
81     ctx->cancel = 1;
82     EndDialog (dlg, FALSE);
83     break;
84     }
85     }
86    
87     return FALSE;
88     }
89    
90    
91     /* Common dialog to request a URL from the user.
92     Return value is the URL context. */
93     void*
94     get_http_file_dlg (HWND root)
95     {
96     struct URL_ctx_s *ctx;
97    
98     ctx = new URL_ctx_s;
99     if (!ctx)
100     BUG (0);
101     memset (ctx, 0, sizeof *ctx);
102     ctx->check = 1;
103     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,
104     http_dlg_proc, (LPARAM)ctx);
105     return ctx;
106     }
107    
108     /* Wrapper to request a preferred keyserver from the user.
109     Return value is the URL context. */
110     void*
111     get_keyserver_URL_dlg (HWND root)
112     {
113     struct URL_ctx_s *ctx;
114    
115     ctx = new URL_ctx_s;
116     if (!ctx)
117     BUG (0);
118     memset (ctx, 0, sizeof *ctx);
119     ctx->check = 1;
120     ctx->desc = _("Key Edit");
121     ctx->title = _("Enter preferred keyserver URL");
122     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,
123     http_dlg_proc, (LPARAM)ctx);
124     return ctx;
125     }
126    
127    
128     /* Generic text input dialog. */
129     char*
130     get_input_dialog (HWND root, const char *title, const char *desc)
131     {
132     struct URL_ctx_s ctx;
133    
134     memset (&ctx, 0, sizeof (ctx));
135     ctx.title = title;
136     ctx.desc = desc;
137     DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,
138     http_dlg_proc, (LPARAM)&ctx);
139     if (ctx.cancel || strlen (ctx.url) == 0)
140     return NULL;
141     return m_strdup (ctx.url);
142     }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26