1 |
/* wptHotkey.cpp - Systemwide hotkeys |
/* wptHotkey.cpp - Systemwide hotkeys |
2 |
* Copyright (C) 2001, 2002, 2003, 2006 Timo Schulz |
* Copyright (C) 2001-2003, 2006, 2008, 2009 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
* General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
15 |
*/ |
*/ |
16 |
|
|
17 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
33 |
/* ALT+CTRL+ */ |
/* ALT+CTRL+ */ |
34 |
{"ClipEncrypt", 1, WPT_CLIP_ENCRYPT_ID, 1, 0, 0x45}, /* E */ |
{"ClipEncrypt", 1, WPT_CLIP_ENCRYPT_ID, 1, 0, 0x45}, /* E */ |
35 |
{"ClipDecrypt", 1, WPT_CLIP_DECRYPT_VERIFY_ID, 1, 0, 0x44}, /* D */ |
{"ClipDecrypt", 1, WPT_CLIP_DECRYPT_VERIFY_ID, 1, 0, 0x44}, /* D */ |
36 |
{"ClipSign", 1, WPT_CLIP_SIGN_ID, 1, 0, 0x53}, /* S */ |
{"ClipSign", 1, WPT_CLIP_SIGN_ID, 1, 0, 0x53}, /* S */ |
37 |
{"ClipSignEnc", 1, WPT_CLIP_SIGN_ENCRYPT_ID, 1, 0, 0x42}, /* B */ |
{"ClipSignEnc", 1, WPT_CLIP_SIGN_ENCRYPT_ID, 1, 0, 0x42}, /* B */ |
38 |
/* ALT+SHIFT+ */ |
/* ALT+SHIFT+ */ |
39 |
{"CwsEncrypt", 1, WPT_CURRWND_ENCRYPT_ID, 0, 1, 0x45}, /* E */ |
{"CwsEncrypt", 1, WPT_CURRWND_ENCRYPT_ID, 0, 1, 0x45}, /* E */ |
40 |
{"CwsDecrypt", 1, WPT_CURRWND_DECRYPT_VERIFY_ID, 0, 1, 0x44}, /* D */ |
{"CwsDecrypt", 1, WPT_CURRWND_DECRYPT_VERIFY_ID, 0, 1, 0x44}, /* D */ |
41 |
{"CwsSign", 1, WPT_CURRWND_SIGN_ID, 0, 1, 0x53}, /* S */ |
{"CwsSign", 1, WPT_CURRWND_SIGN_ID, 0, 1, 0x53}, /* S */ |
42 |
{"CwsSignEnc", 1, WPT_CURRWND_SIGN_ENCRYPT_ID, 0, 1, 0x42}, /* B */ |
{"CwsSignEnc", 1, WPT_CURRWND_SIGN_ENCRYPT_ID, 0, 1, 0x42}, /* B */ |
43 |
/* Agent ALT+CTRL+ */ |
/* Agent ALT+CTRL+ */ |
44 |
{"AgentForget", 1, WPT_AGENT_FORGET_ID, 1, 0, 0x46}, /* F */ |
{"AgentForget", 1, WPT_AGENT_FORGET_ID, 1, 0, 0x46}, /* F */ |
45 |
{0} |
{0} |
47 |
|
|
48 |
|
|
49 |
/* Global error variable. */ |
/* Global error variable. */ |
50 |
static int err_hotkey = 0; |
static int winpt_hotkey_err = 0; |
51 |
|
|
52 |
const char* |
const char* |
53 |
hotkeys_strerror (void) |
hotkeys_strerror (void) |
54 |
{ |
{ |
55 |
switch (err_hotkey) { |
switch (winpt_hotkey_err) { |
56 |
case 0: return NULL; |
case 0: return NULL; |
57 |
case 1: return _("Clipboard Encrypt (ALT+CTRL+E)"); |
case 1: return _("Clipboard Encrypt (ALT+CTRL+E)"); |
58 |
case 2: return _("Clipboard Decrypt/Verify (ALT+CTRL+D)"); |
case 2: return _("Clipboard Decrypt/Verify (ALT+CTRL+D)"); |
64 |
case 8: return _("Current Window Sign Encrypt (ALT+SHIFT+B)"); |
case 8: return _("Current Window Sign Encrypt (ALT+SHIFT+B)"); |
65 |
default:return _("Unknown Hotkey"); |
default:return _("Unknown Hotkey"); |
66 |
} |
} |
67 |
return NULL; |
return _("Unknown Hotkey"); |
68 |
} |
} |
69 |
|
|
70 |
|
|
72 |
int |
int |
73 |
hotkeys_register (HWND wnd) |
hotkeys_register (HWND wnd) |
74 |
{ |
{ |
|
int j; |
|
75 |
int rc = 0; |
int rc = 0; |
76 |
|
|
77 |
err_hotkey = 0; /* reset */ |
winpt_hotkey_err = 0; /* reset */ |
78 |
for (j=0; wpt_hotkeys[j].id != 0; j++) { |
for (int j=0; wpt_hotkeys[j].id != 0; j++) { |
79 |
if (wpt_hotkeys[j].enabled) { |
if (wpt_hotkeys[j].enabled) { |
80 |
rc = hotkey_register_single (wnd, &wpt_hotkeys[j]); |
rc = hotkey_register_single (wnd, &wpt_hotkeys[j]); |
81 |
if (rc) { |
if (rc) { |
82 |
err_hotkey = j+1; |
winpt_hotkey_err = j+1; |
83 |
break; |
break; |
84 |
} |
} |
85 |
} |
} |
93 |
int |
int |
94 |
hotkeys_unregister (HWND wnd) |
hotkeys_unregister (HWND wnd) |
95 |
{ |
{ |
96 |
int j; |
for (int j=0; wpt_hotkeys[j].id != 0; j++) |
|
|
|
|
for (j=0; wpt_hotkeys[j].id != 0; j++) |
|
97 |
hotkey_unregister_single (wnd, &wpt_hotkeys[j]); |
hotkey_unregister_single (wnd, &wpt_hotkeys[j]); |
98 |
|
|
99 |
return 0; |
return 0; |