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

Contents of /trunk/Src/wptHotkey.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (show annotations)
Mon Oct 31 21:14:11 2005 UTC (19 years, 4 months ago) by werner
File size: 3361 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 /* wptHotkey.cpp - Systemwide hotkeys
2 * Copyright (C) 2001, 2002, 2003 Timo Schulz
3 *
4 * This file is part of WinPT.
5 *
6 * WinPT is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (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 GNU
14 * 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 #include "wptHotkey.h"
28 #include "wptGPG.h"
29 #include "wptRegistry.h"
30 #include "wptErrors.h"
31 #include "wptNLS.h"
32 #include "wptTypes.h"
33
34 static int err_hotkey = 0;
35
36 const char *
37 hotkeys_strerror (void)
38 {
39 switch (err_hotkey) {
40 case 0: return NULL;
41 case 1: return _("Clipboard Encrypt (ALT+CTRL+E)");
42 case 2: return _("Clipboard Decrypt/Verify (ALT+CTRL+D)");
43 case 3: return _("Clipboard Sign (ALT+CTRL+S)");
44 case 4: return _("Clipboard Sign Encrypt (ALT+CTRL+B)");
45 case 5: return _("Current Window Encrypt (ALT+SHIFT+E)");
46 case 6: return _("Current Window Decrypt/Verify (ALT+SHIFT+D)");
47 case 7: return _("Current Window Sign (ALT+SHIFT+S)");
48 case 8: return _("Current Window Sign Encrypt (ALT+SHIFT+B");
49 default: return _("Unknown Hotkey");
50 }
51 return NULL;
52 }
53
54
55 int
56 hotkeys_register (HWND wnd)
57 {
58 int j = 0, rc = 0;
59
60 err_hotkey = 0; /* reset */
61 for (j=0; wpt_hotkeys[j].id != 0; j++) {
62 if (wpt_hotkeys[j].enabled) {
63 rc = hotkey_register_single (wnd, &wpt_hotkeys[j]);
64 if (rc) {
65 err_hotkey = j+1;
66 break;
67 }
68 }
69 }
70
71 return rc;
72 } /* hotkeys_register */
73
74
75 int
76 hotkeys_unregister (HWND wnd)
77 {
78 int j = 0, rc = 0;
79
80 for (j=0; wpt_hotkeys[j].id != 0; j++) {
81 if (wpt_hotkeys[j].enabled) {
82 rc = hotkey_unregister_single (wnd, &wpt_hotkeys[j]);
83 if (rc)
84 break;
85 }
86 }
87
88 return rc;
89 } /* hotkeys_unregister */
90
91
92 int
93 hotkey_register_single (HWND wnd, hotkey_t hk)
94 {
95 int rc, keymod;
96
97 if (!hk->enabled)
98 return 0;
99
100 if (hk->alt_ctrl)
101 keymod = MOD_CONTROL | MOD_ALT;
102 else if (hk->alt_shift)
103 keymod = MOD_ALT | MOD_SHIFT;
104
105 rc = RegisterHotKey (wnd, hk->id, keymod, hk->key);
106 if (!rc)
107 return WPTERR_HOTKEY;
108 return 0;
109 } /* hotkey_register_single */
110
111 int
112 hotkey_unregister_single (HWND wnd, hotkey_t hk)
113 {
114 int rc = UnregisterHotKey (wnd, hk->id);
115 return rc==0? WPTERR_HOTKEY: 0;
116 } /* hotkey_unregister_single */
117
118
119 void
120 hotkeys_modify (void)
121 {
122 int i;
123
124 for (i = 0; wpt_hotkeys[i].id; i++) {
125 if( reg_hotkeys[i].enabled ) {
126 wpt_hotkeys[i].key = reg_hotkeys[i].key[0];
127 wpt_hotkeys[i].enabled = 1;
128 }
129 }
130 } /* hotkeys_modify */
131
132
133 void
134 hotkey_disable (reg_hotkey_t rhk)
135 {
136 strcpy (rhk->key, " ");
137 rhk->enabled = 0;
138 } /* hotkey_disable */
139
140
141 void
142 hotkey_enable (reg_hotkey_t rhk, const char * key)
143 {
144 if (strlen (key) > 2)
145 BUG (0);
146 strcpy (rhk->key, key);
147 rhk->enabled = 1;
148 } /* hotkey_enable */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26