wmaker: Created an array to hold the maximize menu entries
[wmaker-crm.git] / WPrefs.app / KeyboardShortcuts.c
blob19e9905bb0ca7f82ade6f9784cd3e64a25ab0165
1 /* KeyboardShortcuts.c- keyboard shortcut bindings
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2003 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "config.h" /* for HAVE_XCONVERTCASE */
24 #include "WPrefs.h"
25 #include <ctype.h>
27 #include <X11/keysym.h>
28 #include <X11/XKBlib.h>
30 typedef struct _Panel {
31 WMBox *box;
33 char *sectionName;
35 char *description;
37 CallbackRec callbacks;
39 WMWidget *parent;
41 WMLabel *actL;
42 WMList *actLs;
44 WMFrame *shoF;
45 WMTextField *shoT;
46 WMButton *cleB;
47 WMButton *defB;
49 WMLabel *instructionsL;
51 WMColor *white;
52 WMColor *black;
53 WMColor *gray;
54 WMFont *font;
56 Bool capturing;
57 char **shortcuts;
58 int actionCount;
59 } _Panel;
61 #define ICON_FILE "keyshortcuts"
64 * List of user definable shortcut keys
65 * First parameter is the internal keyword known by WMaker
66 * Second is the text displayed to the user
68 static const struct {
69 const char *key;
70 const char *title;
71 } keyOptions[] = {
72 { "RootMenuKey", N_("Open applications menu") },
73 { "WindowListKey", N_("Open window list menu") },
74 { "WindowMenuKey", N_("Open window commands menu") },
75 { "HideKey", N_("Hide active application") },
76 { "HideOthersKey", N_("Hide other applications") },
77 { "MiniaturizeKey", N_("Miniaturize active window") },
78 { "MinimizeAllKey", N_("Miniaturize all windows") },
79 { "CloseKey", N_("Close active window") },
80 { "MaximizeKey", N_("Maximize active window") },
81 { "VMaximizeKey", N_("Maximize active window vertically") },
82 { "HMaximizeKey", N_("Maximize active window horizontally") },
83 { "LHMaximizeKey", N_("Maximize active window left half") },
84 { "RHMaximizeKey", N_("Maximize active window right half") },
85 { "THMaximizeKey", N_("Maximize active window top half") },
86 { "BHMaximizeKey", N_("Maximize active window bottom half") },
87 { "LTCMaximizeKey", N_("Maximize active window left top corner") },
88 { "RTCMaximizeKey", N_("Maximize active window right top corner") },
89 { "LBCMaximizeKey", N_("Maximize active window left bottom corner") },
90 { "RBCMaximizeKey", N_("Maximize active window right bottom corner") },
91 { "MaximusKey", N_("Maximus: Tiled maximization ") },
92 { "RaiseKey", N_("Raise active window") },
93 { "LowerKey", N_("Lower active window") },
94 { "RaiseLowerKey", N_("Raise/Lower window under mouse pointer") },
95 { "ShadeKey", N_("Shade active window") },
96 { "MoveResizeKey", N_("Move/Resize active window") },
97 { "SelectKey", N_("Select active window") },
98 { "FocusNextKey", N_("Focus next window") },
99 { "FocusPrevKey", N_("Focus previous window") },
100 { "GroupNextKey", N_("Focus next group window") },
101 { "GroupPrevKey", N_("Focus previous group window") },
103 /* Workspace Related */
104 { "NextWorkspaceKey", N_("Switch to next workspace") },
105 { "PrevWorkspaceKey", N_("Switch to previous workspace") },
106 { "LastWorkspaceKey", N_("Switch to last used workspace") },
107 { "NextWorkspaceLayerKey", N_("Switch to next ten workspaces") },
108 { "PrevWorkspaceLayerKey", N_("Switch to previous ten workspaces") },
109 { "Workspace1Key", N_("Switch to workspace 1") },
110 { "Workspace2Key", N_("Switch to workspace 2") },
111 { "Workspace3Key", N_("Switch to workspace 3") },
112 { "Workspace4Key", N_("Switch to workspace 4") },
113 { "Workspace5Key", N_("Switch to workspace 5") },
114 { "Workspace6Key", N_("Switch to workspace 6") },
115 { "Workspace7Key", N_("Switch to workspace 7") },
116 { "Workspace8Key", N_("Switch to workspace 8") },
117 { "Workspace9Key", N_("Switch to workspace 9") },
118 { "Workspace10Key", N_("Switch to workspace 10") },
119 { "MoveToNextWorkspaceKey", N_("Move window to next workspace") },
120 { "MoveToPrevWorkspaceKey", N_("Move window to previous workspace") },
121 { "MoveToLastWorkspaceKey", N_("Move window to last used workspace") },
122 { "MoveToNextWorkspaceLayerKey", N_("Move window to next ten workspaces") },
123 { "MoveToPrevWorkspaceLayerKey", N_("Move window to previous ten workspaces") },
124 { "MoveToWorkspace1Key", N_("Move window to workspace 1") },
125 { "MoveToWorkspace2Key", N_("Move window to workspace 2") },
126 { "MoveToWorkspace3Key", N_("Move window to workspace 3") },
127 { "MoveToWorkspace4Key", N_("Move window to workspace 4") },
128 { "MoveToWorkspace5Key", N_("Move window to workspace 5") },
129 { "MoveToWorkspace6Key", N_("Move window to workspace 6") },
130 { "MoveToWorkspace7Key", N_("Move window to workspace 7") },
131 { "MoveToWorkspace8Key", N_("Move window to workspace 8") },
132 { "MoveToWorkspace9Key", N_("Move window to workspace 9") },
133 { "MoveToWorkspace10Key", N_("Move window to workspace 10") },
135 /* Window Selection */
136 { "WindowShortcut1Key", N_("Shortcut for window 1") },
137 { "WindowShortcut2Key", N_("Shortcut for window 2") },
138 { "WindowShortcut3Key", N_("Shortcut for window 3") },
139 { "WindowShortcut4Key", N_("Shortcut for window 4") },
140 { "WindowShortcut5Key", N_("Shortcut for window 5") },
141 { "WindowShortcut6Key", N_("Shortcut for window 6") },
142 { "WindowShortcut7Key", N_("Shortcut for window 7") },
143 { "WindowShortcut8Key", N_("Shortcut for window 8") },
144 { "WindowShortcut9Key", N_("Shortcut for window 9") },
145 { "WindowShortcut10Key", N_("Shortcut for window 10") },
147 /* Misc. */
148 { "WindowRelaunchKey", N_("Launch new instance of application") },
149 { "ScreenSwitchKey", N_("Switch to Next Screen/Monitor") },
150 { "DockRaiseLowerKey", N_("Raise/Lower Dock") },
151 { "ClipRaiseLowerKey", N_("Raise/Lower Clip") }
152 #ifdef XKB_MODELOCK
153 ,{ "ToggleKbdModeKey", N_("Toggle keyboard language") }
154 #endif /* XKB_MODELOCK */
157 #ifndef HAVE_XCONVERTCASE
158 /* from Xlib */
160 static void XConvertCase(register KeySym sym, KeySym * lower, KeySym * upper)
162 *lower = sym;
163 *upper = sym;
164 switch (sym >> 8) {
165 case 0: /* Latin 1 */
166 if ((sym >= XK_A) && (sym <= XK_Z))
167 *lower += (XK_a - XK_A);
168 else if ((sym >= XK_a) && (sym <= XK_z))
169 *upper -= (XK_a - XK_A);
170 else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
171 *lower += (XK_agrave - XK_Agrave);
172 else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis))
173 *upper -= (XK_agrave - XK_Agrave);
174 else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn))
175 *lower += (XK_oslash - XK_Ooblique);
176 else if ((sym >= XK_oslash) && (sym <= XK_thorn))
177 *upper -= (XK_oslash - XK_Ooblique);
178 break;
179 case 1: /* Latin 2 */
180 /* Assume the KeySym is a legal value (ignore discontinuities) */
181 if (sym == XK_Aogonek)
182 *lower = XK_aogonek;
183 else if (sym >= XK_Lstroke && sym <= XK_Sacute)
184 *lower += (XK_lstroke - XK_Lstroke);
185 else if (sym >= XK_Scaron && sym <= XK_Zacute)
186 *lower += (XK_scaron - XK_Scaron);
187 else if (sym >= XK_Zcaron && sym <= XK_Zabovedot)
188 *lower += (XK_zcaron - XK_Zcaron);
189 else if (sym == XK_aogonek)
190 *upper = XK_Aogonek;
191 else if (sym >= XK_lstroke && sym <= XK_sacute)
192 *upper -= (XK_lstroke - XK_Lstroke);
193 else if (sym >= XK_scaron && sym <= XK_zacute)
194 *upper -= (XK_scaron - XK_Scaron);
195 else if (sym >= XK_zcaron && sym <= XK_zabovedot)
196 *upper -= (XK_zcaron - XK_Zcaron);
197 else if (sym >= XK_Racute && sym <= XK_Tcedilla)
198 *lower += (XK_racute - XK_Racute);
199 else if (sym >= XK_racute && sym <= XK_tcedilla)
200 *upper -= (XK_racute - XK_Racute);
201 break;
202 case 2: /* Latin 3 */
203 /* Assume the KeySym is a legal value (ignore discontinuities) */
204 if (sym >= XK_Hstroke && sym <= XK_Hcircumflex)
205 *lower += (XK_hstroke - XK_Hstroke);
206 else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex)
207 *lower += (XK_gbreve - XK_Gbreve);
208 else if (sym >= XK_hstroke && sym <= XK_hcircumflex)
209 *upper -= (XK_hstroke - XK_Hstroke);
210 else if (sym >= XK_gbreve && sym <= XK_jcircumflex)
211 *upper -= (XK_gbreve - XK_Gbreve);
212 else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex)
213 *lower += (XK_cabovedot - XK_Cabovedot);
214 else if (sym >= XK_cabovedot && sym <= XK_scircumflex)
215 *upper -= (XK_cabovedot - XK_Cabovedot);
216 break;
217 case 3: /* Latin 4 */
218 /* Assume the KeySym is a legal value (ignore discontinuities) */
219 if (sym >= XK_Rcedilla && sym <= XK_Tslash)
220 *lower += (XK_rcedilla - XK_Rcedilla);
221 else if (sym >= XK_rcedilla && sym <= XK_tslash)
222 *upper -= (XK_rcedilla - XK_Rcedilla);
223 else if (sym == XK_ENG)
224 *lower = XK_eng;
225 else if (sym == XK_eng)
226 *upper = XK_ENG;
227 else if (sym >= XK_Amacron && sym <= XK_Umacron)
228 *lower += (XK_amacron - XK_Amacron);
229 else if (sym >= XK_amacron && sym <= XK_umacron)
230 *upper -= (XK_amacron - XK_Amacron);
231 break;
232 case 6: /* Cyrillic */
233 /* Assume the KeySym is a legal value (ignore discontinuities) */
234 if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE)
235 *lower -= (XK_Serbian_DJE - XK_Serbian_dje);
236 else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze)
237 *upper += (XK_Serbian_DJE - XK_Serbian_dje);
238 else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN)
239 *lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu);
240 else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign)
241 *upper += (XK_Cyrillic_YU - XK_Cyrillic_yu);
242 break;
243 case 7: /* Greek */
244 /* Assume the KeySym is a legal value (ignore discontinuities) */
245 if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent)
246 *lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
247 else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent &&
248 sym != XK_Greek_iotaaccentdieresis && sym != XK_Greek_upsilonaccentdieresis)
249 *upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
250 else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA)
251 *lower += (XK_Greek_alpha - XK_Greek_ALPHA);
252 else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega && sym != XK_Greek_finalsmallsigma)
253 *upper -= (XK_Greek_alpha - XK_Greek_ALPHA);
254 break;
255 case 0x14: /* Armenian */
256 if (sym >= XK_Armenian_AYB && sym <= XK_Armenian_fe) {
257 *lower = sym | 1;
258 *upper = sym & ~1;
260 break;
263 #endif
265 static int NumLockMask(Display *dpy)
267 int i;
268 XModifierKeymap *map = XGetModifierMapping(dpy);
269 KeyCode numlock_keycode = XKeysymToKeycode(dpy, XK_Num_Lock);
270 if (numlock_keycode == NoSymbol)
271 return 0;
273 for (i = 0; i < 8; i++) {
274 if (map->modifiermap[map->max_keypermod * i] == numlock_keycode)
275 return 1 << i;
278 return 0;
281 char *capture_shortcut(Display *dpy, Bool *capturing, Bool convert_case)
283 XEvent ev;
284 KeySym ksym, lksym, uksym;
285 char buffer[64];
286 char *key = NULL;
288 while (*capturing) {
289 XAllowEvents(dpy, AsyncKeyboard, CurrentTime);
290 WMNextEvent(dpy, &ev);
291 if (ev.type == KeyPress && ev.xkey.keycode != 0) {
292 if (xext_xkb_supported)
293 ksym = XkbKeycodeToKeysym(dpy, ev.xkey.keycode, 0, 0);
294 else
295 ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0);
296 if (!IsModifierKey(ksym)) {
297 if (convert_case) {
298 XConvertCase(ksym, &lksym, &uksym);
299 key = XKeysymToString(uksym);
300 } else {
301 key = XKeysymToString(ksym);
304 *capturing = 0;
305 break;
308 WMHandleEvent(&ev);
311 if (!key)
312 return NULL;
314 buffer[0] = 0;
316 if (ev.xkey.state & ControlMask)
317 strcat(buffer, "Control+");
319 if (ev.xkey.state & ShiftMask)
320 strcat(buffer, "Shift+");
322 if ((ev.xkey.state & Mod1Mask) && !NumLockMask(dpy))
323 strcat(buffer, "Mod1+");
325 if ((ev.xkey.state & Mod2Mask) && !NumLockMask(dpy))
326 strcat(buffer, "Mod2+");
328 if ((ev.xkey.state & Mod3Mask) && !NumLockMask(dpy))
329 strcat(buffer, "Mod3+");
331 if ((ev.xkey.state & Mod4Mask) && !NumLockMask(dpy))
332 strcat(buffer, "Mod4+");
334 if ((ev.xkey.state & Mod5Mask) && !NumLockMask(dpy))
335 strcat(buffer, "Mod5+");
337 strcat(buffer, key);
339 return wstrdup(buffer);
342 static void captureClick(WMWidget * w, void *data)
344 _Panel *panel = (_Panel *) data;
345 Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent));
346 char *shortcut;
348 if (!panel->capturing) {
349 panel->capturing = 1;
350 WMSetButtonText(w, _("Cancel"));
351 WMSetLabelText(panel->instructionsL,
352 _("Press the desired shortcut key(s) or click Cancel to stop capturing."));
353 XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, GrabModeAsync, CurrentTime);
354 shortcut = capture_shortcut(dpy, &panel->capturing, 1);
355 if (shortcut) {
356 int row = WMGetListSelectedItemRow(panel->actLs);
358 WMSetTextFieldText(panel->shoT, shortcut);
359 if (row >= 0) {
360 if (panel->shortcuts[row])
361 wfree(panel->shortcuts[row]);
362 panel->shortcuts[row] = shortcut;
364 WMRedisplayWidget(panel->actLs);
365 } else {
366 wfree(shortcut);
370 panel->capturing = 0;
371 WMSetButtonText(w, _("Capture"));
372 WMSetLabelText(panel->instructionsL, _("Click on Capture to interactively define the shortcut key."));
373 XUngrabKeyboard(dpy, CurrentTime);
376 static void clearShortcut(WMWidget * w, void *data)
378 _Panel *panel = (_Panel *) data;
379 int row = WMGetListSelectedItemRow(panel->actLs);
381 /* Parameter not used, but tell the compiler that it is ok */
382 (void) w;
384 WMSetTextFieldText(panel->shoT, NULL);
386 if (row >= 0) {
387 if (panel->shortcuts[row])
388 wfree(panel->shortcuts[row]);
389 panel->shortcuts[row] = NULL;
390 WMRedisplayWidget(panel->actLs);
394 static void typedKeys(void *observerData, WMNotification * notification)
396 _Panel *panel = (_Panel *) observerData;
397 int row = WMGetListSelectedItemRow(panel->actLs);
399 /* Parameter not used, but tell the compiler that it is ok */
400 (void) notification;
402 if (row < 0)
403 return;
405 if (panel->shortcuts[row])
406 wfree(panel->shortcuts[row]);
407 panel->shortcuts[row] = WMGetTextFieldText(panel->shoT);
408 if (strlen(panel->shortcuts[row]) == 0) {
409 wfree(panel->shortcuts[row]);
410 panel->shortcuts[row] = NULL;
412 WMRedisplayWidget(panel->actLs);
415 static void listClick(WMWidget * w, void *data)
417 _Panel *panel = (_Panel *) data;
418 int row = WMGetListSelectedItemRow(w);
420 WMSetTextFieldText(panel->shoT, panel->shortcuts[row]);
423 static void showData(_Panel * panel)
425 char *str;
426 int i;
428 for (i = 0; i < panel->actionCount; i++) {
430 str = GetStringForKey(keyOptions[i].key);
431 if (panel->shortcuts[i])
432 wfree(panel->shortcuts[i]);
433 if (str)
434 panel->shortcuts[i] = wtrimspace(str);
435 else
436 panel->shortcuts[i] = NULL;
438 if (panel->shortcuts[i] &&
439 (strcasecmp(panel->shortcuts[i], "none") == 0 || strlen(panel->shortcuts[i]) == 0)) {
440 wfree(panel->shortcuts[i]);
441 panel->shortcuts[i] = NULL;
444 WMRedisplayWidget(panel->actLs);
447 static void paintItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
449 int width, height, x, y;
450 _Panel *panel = (_Panel *) WMGetHangedData(lPtr);
451 WMScreen *scr = WMWidgetScreen(lPtr);
452 Display *dpy = WMScreenDisplay(scr);
453 WMColor *backColor = (state & WLDSSelected) ? panel->white : panel->gray;
455 width = rect->size.width;
456 height = rect->size.height;
457 x = rect->pos.x;
458 y = rect->pos.y;
460 XFillRectangle(dpy, d, WMColorGC(backColor), x, y, width, height);
462 if (panel->shortcuts[index]) {
463 WMPixmap *pix = WMGetSystemPixmap(scr, WSICheckMark);
464 WMSize size = WMGetPixmapSize(pix);
466 WMDrawPixmap(pix, d, x + (20 - size.width) / 2, (height - size.height) / 2 + y);
467 WMReleasePixmap(pix);
470 WMDrawString(scr, d, panel->black, panel->font, x + 20, y, text, strlen(text));
473 static void createPanel(Panel * p)
475 _Panel *panel = (_Panel *) p;
476 WMScreen *scr = WMWidgetScreen(panel->parent);
477 WMColor *color;
478 WMFont *boldFont;
479 int i;
481 panel->capturing = 0;
483 panel->white = WMWhiteColor(scr);
484 panel->black = WMBlackColor(scr);
485 panel->gray = WMGrayColor(scr);
486 panel->font = WMSystemFontOfSize(scr, 12);
488 panel->box = WMCreateBox(panel->parent);
489 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
491 boldFont = WMBoldSystemFontOfSize(scr, 12);
493 /* **************** Actions **************** */
494 panel->actL = WMCreateLabel(panel->box);
495 WMResizeWidget(panel->actL, 280, 20);
496 WMMoveWidget(panel->actL, 20, 10);
497 WMSetLabelFont(panel->actL, boldFont);
498 WMSetLabelText(panel->actL, _("Actions"));
499 WMSetLabelRelief(panel->actL, WRSunken);
500 WMSetLabelTextAlignment(panel->actL, WACenter);
501 color = WMDarkGrayColor(scr);
502 WMSetWidgetBackgroundColor(panel->actL, color);
503 WMReleaseColor(color);
504 WMSetLabelTextColor(panel->actL, panel->white);
506 panel->actLs = WMCreateList(panel->box);
507 WMResizeWidget(panel->actLs, 280, 190);
508 WMMoveWidget(panel->actLs, 20, 32);
509 WMSetListUserDrawProc(panel->actLs, paintItem);
510 WMHangData(panel->actLs, panel);
512 for (i = 0; i < wlengthof(keyOptions); i++) {
513 WMAddListItem(panel->actLs, _(keyOptions[i].title));
515 WMSetListAction(panel->actLs, listClick, panel);
517 panel->actionCount = WMGetListNumberOfRows(panel->actLs);
518 panel->shortcuts = wmalloc(sizeof(char *) * panel->actionCount);
520 /***************** Shortcut ****************/
522 panel->shoF = WMCreateFrame(panel->box);
523 WMResizeWidget(panel->shoF, 190, 210);
524 WMMoveWidget(panel->shoF, 315, 10);
525 WMSetFrameTitle(panel->shoF, _("Shortcut"));
527 panel->shoT = WMCreateTextField(panel->shoF);
528 WMResizeWidget(panel->shoT, 160, 20);
529 WMMoveWidget(panel->shoT, 15, 65);
530 WMAddNotificationObserver(typedKeys, panel, WMTextDidChangeNotification, panel->shoT);
532 panel->cleB = WMCreateCommandButton(panel->shoF);
533 WMResizeWidget(panel->cleB, 75, 24);
534 WMMoveWidget(panel->cleB, 15, 95);
535 WMSetButtonText(panel->cleB, _("Clear"));
536 WMSetButtonAction(panel->cleB, clearShortcut, panel);
538 panel->defB = WMCreateCommandButton(panel->shoF);
539 WMResizeWidget(panel->defB, 75, 24);
540 WMMoveWidget(panel->defB, 100, 95);
541 WMSetButtonText(panel->defB, _("Capture"));
542 WMSetButtonAction(panel->defB, captureClick, panel);
544 panel->instructionsL = WMCreateLabel(panel->shoF);
545 WMResizeWidget(panel->instructionsL, 160, 55);
546 WMMoveWidget(panel->instructionsL, 15, 140);
547 WMSetLabelTextAlignment(panel->instructionsL, WACenter);
548 WMSetLabelWraps(panel->instructionsL, True);
549 WMSetLabelText(panel->instructionsL, _("Click on Capture to interactively define the shortcut key."));
551 WMMapSubwidgets(panel->shoF);
553 WMReleaseFont(boldFont);
555 WMRealizeWidget(panel->box);
556 WMMapSubwidgets(panel->box);
558 showData(panel);
561 static void storeData(_Panel * panel)
563 int i;
564 char *str;
566 for (i = 0; i < panel->actionCount; i++) {
567 str = NULL;
568 if (panel->shortcuts[i]) {
569 str = wtrimspace(panel->shortcuts[i]);
570 if (strlen(str) == 0) {
571 wfree(str);
572 str = NULL;
575 if (str) {
576 SetStringForKey(str, keyOptions[i].key);
577 wfree(str);
578 } else {
579 SetStringForKey("None", keyOptions[i].key);
584 Panel *InitKeyboardShortcuts(WMWidget *parent)
586 _Panel *panel;
588 panel = wmalloc(sizeof(_Panel));
590 panel->sectionName = _("Keyboard Shortcut Preferences");
592 panel->description = _("Change the keyboard shortcuts for actions such\n"
593 "as changing workspaces and opening menus.");
595 panel->parent = parent;
597 panel->callbacks.createWidgets = createPanel;
598 panel->callbacks.updateDomain = storeData;
600 AddSection(panel, ICON_FILE);
602 return panel;