1 /* Menu.c- menu definition
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 2000-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.
26 #include <X11/keysym.h>
27 #include <X11/cursorfont.h>
43 #define MAX_SECTION_SIZE 4
46 typedef struct _Panel
{
52 CallbackRec callbacks
;
61 WMPixmap
*markerPix
[LastInfo
];
74 WMTextField
*commandT
; /* command to run */
76 WMButton
*xtermC
; /* inside xterm? */
89 WMTextField
*dcommandT
;
105 Bool dontAsk
; /* whether to comfirm submenu remove */
110 /* about the currently selected item */
111 WEditMenuItem
*currentItem
;
112 InfoType currentType
;
113 WMWidget
*sections
[LastInfo
][MAX_SECTION_SIZE
];
143 static char *commandNames
[] = {
158 #define NEW(type) memset(wmalloc(sizeof(type)), 0, sizeof(type))
160 #define ICON_FILE "menus"
162 static void showData(_Panel
* panel
);
164 static void updateMenuItem(_Panel
* panel
, WEditMenuItem
* item
, WMWidget
* changedWidget
);
166 static void menuItemSelected(struct WEditMenuDelegate
*delegate
, WEditMenu
* menu
, WEditMenuItem
* item
);
168 static void menuItemDeselected(struct WEditMenuDelegate
*delegate
, WEditMenu
* menu
, WEditMenuItem
* item
);
170 static void menuItemCloned(struct WEditMenuDelegate
*delegate
, WEditMenu
* menu
,
171 WEditMenuItem
* origItem
, WEditMenuItem
* newItem
);
173 static void menuItemEdited(struct WEditMenuDelegate
*delegate
, WEditMenu
* menu
, WEditMenuItem
* item
);
175 static Bool
shouldRemoveItem(struct WEditMenuDelegate
*delegate
, WEditMenu
* menu
, WEditMenuItem
* item
);
177 static void freeItemData(ItemData
* data
);
179 extern char *capture_shortcut(Display
*dpy
, Bool
*capturing
, Bool convert_case
);
181 static WEditMenuDelegate menuDelegate
= {
190 static void dataChanged(void *self
, WMNotification
* notif
)
192 _Panel
*panel
= (_Panel
*) self
;
193 WEditMenuItem
*item
= panel
->currentItem
;
194 WMWidget
*w
= (WMWidget
*) WMGetNotificationObject(notif
);
196 updateMenuItem(panel
, item
, w
);
199 static void buttonClicked(WMWidget
* w
, void *data
)
201 _Panel
*panel
= (_Panel
*) data
;
202 WEditMenuItem
*item
= panel
->currentItem
;
204 updateMenuItem(panel
, item
, w
);
207 static void icommandLClicked(WMWidget
* w
, void *data
)
209 _Panel
*panel
= (_Panel
*) data
;
212 cmd
= WMGetListSelectedItemRow(w
);
213 if (cmd
== 3 || cmd
== 4) {
214 WMMapWidget(panel
->quickB
);
216 WMUnmapWidget(panel
->quickB
);
219 WMMapWidget(panel
->paramF
);
221 WMUnmapWidget(panel
->paramF
);
225 static void browseForFile(WMWidget
* self
, void *clientData
)
227 _Panel
*panel
= (_Panel
*) clientData
;
228 WMFilePanel
*filePanel
;
229 char *text
, *oldprog
, *newprog
;
231 filePanel
= WMGetOpenPanel(WMWidgetScreen(self
));
232 text
= WMGetTextFieldText(panel
->commandT
);
234 oldprog
= wtrimspace(text
);
237 if (oldprog
[0] == 0 || oldprog
[0] != '/') {
239 oldprog
= wstrdup("/");
242 while (*ptr
&& !isspace(*ptr
))
247 WMSetFilePanelCanChooseDirectories(filePanel
, False
);
249 if (WMRunModalFilePanelForDirectory(filePanel
, panel
->parent
, oldprog
, _("Select Program"), NULL
) == True
) {
250 newprog
= WMGetFilePanelFileName(filePanel
);
251 WMSetTextFieldText(panel
->commandT
, newprog
);
252 updateMenuItem(panel
, panel
->currentItem
, panel
->commandT
);
259 static void sgrabClicked(WMWidget
* w
, void *data
)
261 _Panel
*panel
= (_Panel
*) data
;
262 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->parent
));
265 if (w
== panel
->sclearB
) {
266 WMSetTextFieldText(panel
->shortT
, "");
267 updateMenuItem(panel
, panel
->currentItem
, panel
->shortT
);
271 if (!panel
->capturing
) {
272 panel
->capturing
= 1;
273 WMSetButtonText(w
, _("Cancel"));
274 XGrabKeyboard(dpy
, WMWidgetXID(panel
->parent
), True
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
275 shortcut
= capture_shortcut(dpy
, &panel
->capturing
, 0);
277 WMSetTextFieldText(panel
->shortT
, shortcut
);
278 updateMenuItem(panel
, panel
->currentItem
, panel
->shortT
);
282 panel
->capturing
= 0;
283 WMSetButtonText(w
, _("Capture"));
284 XUngrabKeyboard(dpy
, CurrentTime
);
287 static void changedItemPad(WMWidget
* w
, void *data
)
289 _Panel
*panel
= (_Panel
*) data
;
290 int padn
= WMGetPopUpButtonSelectedItem(w
);
292 WMUnmapWidget(panel
->itemPad
[panel
->currentPad
]);
293 WMMapWidget(panel
->itemPad
[padn
]);
295 panel
->currentPad
= padn
;
298 static WEditMenu
*putNewSubmenu(WEditMenu
* menu
, char *title
)
303 item
= WAddMenuItemWithTitle(menu
, title
);
305 tmp
= WCreateEditMenu(WMWidgetScreen(menu
), title
);
306 WSetEditMenuAcceptsDrop(tmp
, True
);
307 WSetEditMenuDelegate(tmp
, &menuDelegate
);
308 WSetEditMenuSubmenu(menu
, item
, tmp
);
313 static ItemData
*putNewItem(_Panel
* panel
, WEditMenu
* menu
, int type
, char *title
)
318 item
= WAddMenuItemWithTitle(menu
, title
);
320 data
= NEW(ItemData
);
322 WSetEditMenuItemData(item
, data
, (WMCallback
*) freeItemData
);
323 WSetEditMenuItemImage(item
, panel
->markerPix
[type
]);
328 static WEditMenu
*makeFactoryMenu(WMWidget
* parent
, int width
)
332 pad
= WCreateEditMenuPad(parent
);
333 WMResizeWidget(pad
, width
, 10);
334 WSetEditMenuMinSize(pad
, wmksize(width
, 0));
335 WSetEditMenuMaxSize(pad
, wmksize(width
, 0));
336 WSetEditMenuSelectable(pad
, False
);
337 WSetEditMenuEditable(pad
, False
);
338 WSetEditMenuIsFactory(pad
, True
);
339 WSetEditMenuDelegate(pad
, &menuDelegate
);
344 static void createPanel(_Panel
* p
)
346 _Panel
*panel
= (_Panel
*) p
;
347 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
348 WMColor
*black
= WMBlackColor(scr
);
349 WMColor
*white
= WMWhiteColor(scr
);
350 WMColor
*gray
= WMGrayColor(scr
);
351 WMFont
*bold
= WMBoldSystemFontOfSize(scr
, 12);
352 WMFont
*font
= WMSystemFontOfSize(scr
, 12);
356 menuDelegate
.data
= panel
;
358 panel
->boldFont
= bold
;
359 panel
->normalFont
= font
;
361 panel
->black
= black
;
362 panel
->white
= white
;
367 Display
*dpy
= WMScreenDisplay(scr
);
371 pixm
= WMCreatePixmap(scr
, 7, 7, WMScreenDepth(scr
), True
);
373 pix
= WMGetPixmapXID(pixm
);
375 XDrawLine(dpy
, pix
, WMColorGC(black
), 0, 3, 6, 3);
376 XDrawLine(dpy
, pix
, WMColorGC(black
), 3, 0, 3, 6);
378 XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3);
379 XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3);
380 XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6);
383 pix
= WMGetPixmapMaskXID(pixm
);
385 gc
= XCreateGC(dpy
, pix
, 0, NULL
);
387 XSetForeground(dpy
, gc
, 0);
388 XFillRectangle(dpy
, pix
, gc
, 0, 0, 7, 7);
390 XSetForeground(dpy
, gc
, 1);
391 XDrawLine(dpy
, pix
, gc
, 0, 3, 6, 3);
392 XDrawLine(dpy
, pix
, gc
, 3, 0, 3, 6);
394 panel
->markerPix
[ExternalInfo
] = pixm
;
395 panel
->markerPix
[PipeInfo
] = pixm
;
396 panel
->markerPix
[DirectoryInfo
] = pixm
;
397 panel
->markerPix
[WSMenuInfo
] = pixm
;
398 panel
->markerPix
[WWindowListInfo
] = pixm
;
403 panel
->box
= WMCreateBox(panel
->parent
);
404 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
406 panel
->typeP
= WMCreatePopUpButton(panel
->box
);
407 WMResizeWidget(panel
->typeP
, 150, 20);
408 WMMoveWidget(panel
->typeP
, 10, 10);
410 WMAddPopUpButtonItem(panel
->typeP
, _("New Items"));
411 WMAddPopUpButtonItem(panel
->typeP
, _("Sample Commands"));
412 WMAddPopUpButtonItem(panel
->typeP
, _("Sample Submenus"));
414 WMSetPopUpButtonAction(panel
->typeP
, changedItemPad
, panel
);
416 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
421 pad
= makeFactoryMenu(panel
->box
, 150);
422 WMMoveWidget(pad
, 10, 40);
424 putNewItem(panel
, pad
, ExecInfo
, _("Run Program"));
425 putNewItem(panel
, pad
, CommandInfo
, _("Internal Command"));
426 putNewSubmenu(pad
, _("Submenu"));
427 putNewItem(panel
, pad
, ExternalInfo
, _("External Submenu"));
428 putNewItem(panel
, pad
, PipeInfo
, _("Generated Submenu"));
429 putNewItem(panel
, pad
, DirectoryInfo
, _("Directory Contents"));
430 putNewItem(panel
, pad
, WSMenuInfo
, _("Workspace Menu"));
431 putNewItem(panel
, pad
, WWindowListInfo
, _("Window List Menu"));
433 panel
->itemPad
[0] = pad
;
441 sview
= WMCreateScrollView(panel
->box
);
442 WMResizeWidget(sview
, 150, 180);
443 WMMoveWidget(sview
, 10, 40);
444 WMSetScrollViewHasVerticalScroller(sview
, True
);
446 pad
= makeFactoryMenu(panel
->box
, 130);
448 WMSetScrollViewContentView(sview
, WMWidgetView(pad
));
450 data
= putNewItem(panel
, pad
, ExecInfo
, _("XTerm"));
451 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg black -fg white";
453 data
= putNewItem(panel
, pad
, ExecInfo
, _("rxvt"));
454 data
->param
.exec
.command
= "rxvt";
456 data
= putNewItem(panel
, pad
, ExecInfo
, _("ETerm"));
457 data
->param
.exec
.command
= "eterm";
459 data
= putNewItem(panel
, pad
, ExecInfo
, _("Run..."));
460 data
->param
.exec
.command
= _("%A(Run,Type command to run)");
462 data
= putNewItem(panel
, pad
, ExecInfo
, _("Firefox"));
463 data
->param
.exec
.command
= "firefox";
465 data
= putNewItem(panel
, pad
, ExecInfo
, _("gimp"));
466 data
->param
.exec
.command
= "gimp";
468 data
= putNewItem(panel
, pad
, ExecInfo
, _("epic"));
469 data
->param
.exec
.command
= "xterm -e epic";
471 data
= putNewItem(panel
, pad
, ExecInfo
, _("ee"));
472 data
->param
.exec
.command
= "ee";
474 data
= putNewItem(panel
, pad
, ExecInfo
, _("xv"));
475 data
->param
.exec
.command
= "xv";
477 data
= putNewItem(panel
, pad
, ExecInfo
, _("Evince"));
478 data
->param
.exec
.command
= "evince";
480 data
= putNewItem(panel
, pad
, ExecInfo
, _("ghostview"));
481 data
->param
.exec
.command
= "gv";
483 data
= putNewItem(panel
, pad
, CommandInfo
, _("Exit Window Maker"));
484 data
->param
.command
.command
= 3;
488 panel
->itemPad
[1] = sview
;
492 WEditMenu
*pad
, *smenu
;
496 sview
= WMCreateScrollView(panel
->box
);
497 WMResizeWidget(sview
, 150, 180);
498 WMMoveWidget(sview
, 10, 40);
499 WMSetScrollViewHasVerticalScroller(sview
, True
);
501 pad
= makeFactoryMenu(panel
->box
, 130);
503 WMSetScrollViewContentView(sview
, WMWidgetView(pad
));
505 data
= putNewItem(panel
, pad
, ExternalInfo
, _("Debian Menu"));
506 data
->param
.pipe
.command
= "/etc/X11/WindowMaker/menu.hook";
508 data
= putNewItem(panel
, pad
, PipeInfo
, _("RedHat Menu"));
509 data
->param
.pipe
.command
= "wmconfig --output wmaker";
511 data
= putNewItem(panel
, pad
, PipeInfo
, _("Menu Conectiva"));
512 data
->param
.pipe
.command
= "wmconfig --output wmaker";
514 data
= putNewItem(panel
, pad
, DirectoryInfo
, _("Themes"));
515 data
->param
.directory
.command
= "setstyle";
516 data
->param
.directory
.directory
=
517 "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes";
518 data
->param
.directory
.stripExt
= 1;
520 data
= putNewItem(panel
, pad
, DirectoryInfo
, _("Bg Images (scale)"));
521 data
->param
.directory
.command
= "wmsetbg -u -s";
522 data
->param
.directory
.directory
=
523 "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds";
524 data
->param
.directory
.stripExt
= 1;
526 data
= putNewItem(panel
, pad
, DirectoryInfo
, _("Bg Images (tile)"));
527 data
->param
.directory
.command
= "wmsetbg -u -t";
528 data
->param
.directory
.directory
=
529 "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds";
530 data
->param
.directory
.stripExt
= 1;
532 smenu
= putNewSubmenu(pad
, _("Assorted XTerms"));
534 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm Yellow on Blue"));
535 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg midnightblue -fg yellow";
537 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm White on Black"));
538 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg black -fg white";
540 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm Black on White"));
541 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg white -fg black";
543 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm Black on Beige"));
544 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg '#bbbb99' -fg black";
546 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm White on Green"));
547 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg '#228822' -fg white";
549 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm White on Olive"));
550 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg '#335533' -fg white";
552 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm Blue on Blue"));
553 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'";
555 data
= putNewItem(panel
, smenu
, ExecInfo
, _("XTerm BIG FONTS"));
556 data
->param
.exec
.command
= "xterm -sb -sl 2000 -bg black -fg white -fn 10x20";
560 panel
->itemPad
[2] = sview
;
563 width
= FRAME_WIDTH
- 20 - 150 - 10 - 2;
565 panel
->optionsF
= WMCreateFrame(panel
->box
);
566 WMResizeWidget(panel
->optionsF
, width
, FRAME_HEIGHT
- 15);
567 WMMoveWidget(panel
->optionsF
, 10 + 150 + 10, 5);
573 panel
->commandF
= WMCreateFrame(panel
->optionsF
);
574 WMResizeWidget(panel
->commandF
, width
, 50);
575 WMMoveWidget(panel
->commandF
, 10, 20);
576 WMSetFrameTitle(panel
->commandF
, _("Program to Run"));
577 WMSetFrameTitlePosition(panel
->commandF
, WTPAtTop
);
579 panel
->commandT
= WMCreateTextField(panel
->commandF
);
580 WMResizeWidget(panel
->commandT
, width
- 95, 20);
581 WMMoveWidget(panel
->commandT
, 10, 20);
583 panel
->browseB
= WMCreateCommandButton(panel
->commandF
);
584 WMResizeWidget(panel
->browseB
, 70, 24);
585 WMMoveWidget(panel
->browseB
, width
- 80, 18);
586 WMSetButtonText(panel
->browseB
, _("Browse"));
587 WMSetButtonAction(panel
->browseB
, browseForFile
, panel
);
589 WMAddNotificationObserver(dataChanged
, panel
, WMTextDidChangeNotification
, panel
->commandT
);
592 panel
->xtermC
= WMCreateSwitchButton(panel
->commandF
);
593 WMResizeWidget(panel
->xtermC
, width
- 20, 20);
594 WMMoveWidget(panel
->xtermC
, 10, 50);
595 WMSetButtonText(panel
->xtermC
, _("Run the program inside a Xterm"));
597 WMMapSubwidgets(panel
->commandF
);
601 panel
->pathF
= WMCreateFrame(panel
->optionsF
);
602 WMResizeWidget(panel
->pathF
, width
, 150);
603 WMMoveWidget(panel
->pathF
, 10, 40);
604 WMSetFrameTitle(panel
->pathF
, _("Path for Menu"));
606 panel
->pathT
= WMCreateTextField(panel
->pathF
);
607 WMResizeWidget(panel
->pathT
, width
- 20, 20);
608 WMMoveWidget(panel
->pathT
, 10, 20);
610 WMAddNotificationObserver(dataChanged
, panel
, WMTextDidChangeNotification
, panel
->pathT
);
612 label
= WMCreateLabel(panel
->pathF
);
613 WMResizeWidget(label
, width
- 20, 80);
614 WMMoveWidget(label
, 10, 50);
615 WMSetLabelText(label
, _("Enter the path for a file containing a menu\n"
616 "or a list of directories with the programs you\n"
617 "want to have listed in the menu. Ex:\n"
618 "~/GNUstep/Library/WindowMaker/menu\n" "or\n" "/usr/X11R6/bin ~/xbin"));
620 WMMapSubwidgets(panel
->pathF
);
624 panel
->pipeF
= WMCreateFrame(panel
->optionsF
);
625 WMResizeWidget(panel
->pipeF
, width
, 155);
626 WMMoveWidget(panel
->pipeF
, 10, 30);
627 WMSetFrameTitle(panel
->pipeF
, _("Command"));
629 panel
->pipeT
= WMCreateTextField(panel
->pipeF
);
630 WMResizeWidget(panel
->pipeT
, width
- 20, 20);
631 WMMoveWidget(panel
->pipeT
, 10, 20);
633 WMAddNotificationObserver(dataChanged
, panel
, WMTextDidChangeNotification
, panel
->pipeT
);
635 label
= WMCreateLabel(panel
->pipeF
);
636 WMResizeWidget(label
, width
- 20, 40);
637 WMMoveWidget(label
, 10, 50);
638 WMSetLabelText(label
, _("Enter a command that outputs a menu\n" "definition to stdout when invoked."));
640 panel
->pipeCacheB
= WMCreateSwitchButton(panel
->pipeF
);
641 WMResizeWidget(panel
->pipeCacheB
, width
- 20, 40);
642 WMMoveWidget(panel
->pipeCacheB
, 10, 110);
643 WMSetButtonText(panel
->pipeCacheB
, _("Cache menu contents after opening for\n" "the first time"));
645 WMMapSubwidgets(panel
->pipeF
);
649 panel
->dcommandF
= WMCreateFrame(panel
->optionsF
);
650 WMResizeWidget(panel
->dcommandF
, width
, 90);
651 WMMoveWidget(panel
->dcommandF
, 10, 25);
652 WMSetFrameTitle(panel
->dcommandF
, _("Command to Open Files"));
654 panel
->dcommandT
= WMCreateTextField(panel
->dcommandF
);
655 WMResizeWidget(panel
->dcommandT
, width
- 20, 20);
656 WMMoveWidget(panel
->dcommandT
, 10, 20);
658 WMAddNotificationObserver(dataChanged
, panel
, WMTextDidChangeNotification
, panel
->dcommandT
);
660 label
= WMCreateLabel(panel
->dcommandF
);
661 WMResizeWidget(label
, width
- 20, 45);
662 WMMoveWidget(label
, 10, 40);
663 WMSetLabelText(label
, _("Enter the command you want to use to open the\n"
664 "files in the directories listed below."));
666 WMMapSubwidgets(panel
->dcommandF
);
668 panel
->dpathF
= WMCreateFrame(panel
->optionsF
);
669 WMResizeWidget(panel
->dpathF
, width
, 80);
670 WMMoveWidget(panel
->dpathF
, 10, 125);
671 WMSetFrameTitle(panel
->dpathF
, _("Directories with Files"));
673 panel
->dpathT
= WMCreateTextField(panel
->dpathF
);
674 WMResizeWidget(panel
->dpathT
, width
- 20, 20);
675 WMMoveWidget(panel
->dpathT
, 10, 20);
677 WMAddNotificationObserver(dataChanged
, panel
, WMTextDidChangeNotification
, panel
->dpathT
);
679 panel
->dstripB
= WMCreateSwitchButton(panel
->dpathF
);
680 WMResizeWidget(panel
->dstripB
, width
- 20, 20);
681 WMMoveWidget(panel
->dstripB
, 10, 50);
682 WMSetButtonText(panel
->dstripB
, _("Strip extensions from file names"));
684 WMSetButtonAction(panel
->dstripB
, buttonClicked
, panel
);
686 WMMapSubwidgets(panel
->dpathF
);
690 panel
->shortF
= WMCreateFrame(panel
->optionsF
);
691 WMResizeWidget(panel
->shortF
, width
, 50);
692 WMMoveWidget(panel
->shortF
, 10, 160);
693 WMSetFrameTitle(panel
->shortF
, _("Keyboard Shortcut"));
695 panel
->shortT
= WMCreateTextField(panel
->shortF
);
696 WMResizeWidget(panel
->shortT
, width
- 20 - 150, 20);
697 WMMoveWidget(panel
->shortT
, 10, 20);
699 WMAddNotificationObserver(dataChanged
, panel
, WMTextDidChangeNotification
, panel
->shortT
);
701 panel
->sgrabB
= WMCreateCommandButton(panel
->shortF
);
702 WMResizeWidget(panel
->sgrabB
, 70, 24);
703 WMMoveWidget(panel
->sgrabB
, width
- 80, 18);
704 WMSetButtonText(panel
->sgrabB
, _("Capture"));
705 WMSetButtonAction(panel
->sgrabB
, sgrabClicked
, panel
);
707 panel
->sclearB
= WMCreateCommandButton(panel
->shortF
);
708 WMResizeWidget(panel
->sclearB
, 70, 24);
709 WMMoveWidget(panel
->sclearB
, width
- 155, 18);
710 WMSetButtonText(panel
->sclearB
, _("Clear"));
711 WMSetButtonAction(panel
->sclearB
, sgrabClicked
, panel
);
713 WMMapSubwidgets(panel
->shortF
);
715 /* internal command */
717 panel
->icommandL
= WMCreateList(panel
->optionsF
);
718 WMResizeWidget(panel
->icommandL
, width
, 80);
719 WMMoveWidget(panel
->icommandL
, 10, 20);
721 WMSetListAction(panel
->icommandL
, icommandLClicked
, panel
);
723 WMAddNotificationObserver(dataChanged
, panel
, WMListSelectionDidChangeNotification
, panel
->icommandL
);
725 WMInsertListItem(panel
->icommandL
, 0, _("Arrange Icons"));
726 WMInsertListItem(panel
->icommandL
, 1, _("Hide All Windows Except For The Focused One"));
727 WMInsertListItem(panel
->icommandL
, 2, _("Show All Windows"));
729 WMInsertListItem(panel
->icommandL
, 3, _("Exit Window Maker"));
730 WMInsertListItem(panel
->icommandL
, 4, _("Exit X Session"));
731 WMInsertListItem(panel
->icommandL
, 5, _("Restart Window Maker"));
732 WMInsertListItem(panel
->icommandL
, 6, _("Start Another Window Manager : ("));
734 WMInsertListItem(panel
->icommandL
, 7, _("Save Current Session"));
735 WMInsertListItem(panel
->icommandL
, 8, _("Clear Saved Session"));
736 WMInsertListItem(panel
->icommandL
, 9, _("Refresh Screen"));
737 WMInsertListItem(panel
->icommandL
, 10, _("Open Info Panel"));
738 WMInsertListItem(panel
->icommandL
, 11, _("Open Copyright Panel"));
740 panel
->paramF
= WMCreateFrame(panel
->optionsF
);
741 WMResizeWidget(panel
->paramF
, width
, 50);
742 WMMoveWidget(panel
->paramF
, 10, 105);
743 WMSetFrameTitle(panel
->paramF
, _("Window Manager to Start"));
745 panel
->paramT
= WMCreateTextField(panel
->paramF
);
746 WMResizeWidget(panel
->paramT
, width
- 20, 20);
747 WMMoveWidget(panel
->paramT
, 10, 20);
749 WMAddNotificationObserver(dataChanged
, panel
, WMTextDidChangeNotification
, panel
->paramT
);
751 WMMapSubwidgets(panel
->paramF
);
753 panel
->quickB
= WMCreateSwitchButton(panel
->optionsF
);
754 WMResizeWidget(panel
->quickB
, width
, 20);
755 WMMoveWidget(panel
->quickB
, 10, 120);
756 WMSetButtonText(panel
->quickB
, _("Do not confirm action."));
757 WMSetButtonAction(panel
->quickB
, buttonClicked
, panel
);
759 label
= WMCreateLabel(panel
->optionsF
);
760 WMResizeWidget(label
, width
+ 5, FRAME_HEIGHT
- 50);
761 WMMoveWidget(label
, 7, 20);
762 WMSetLabelText(label
,
763 _("Instructions:\n\n"
764 " - drag items from the left to the menu to add new items\n"
765 " - drag items out of the menu to remove items\n"
766 " - drag items in menu to change their position\n"
767 " - drag items with Control pressed to copy them\n"
768 " - double click in a menu item to change the label\n"
769 " - click on a menu item to change related information"));
772 WMRealizeWidget(panel
->box
);
773 WMMapSubwidgets(panel
->box
);
774 WMMapWidget(panel
->box
);
778 for (i
= 0; i
< 3; i
++)
779 WMUnmapWidget(panel
->itemPad
[i
]);
781 changedItemPad(panel
->typeP
, panel
);
783 panel
->sections
[NoInfo
][0] = label
;
785 panel
->sections
[ExecInfo
][0] = panel
->commandF
;
786 panel
->sections
[ExecInfo
][1] = panel
->shortF
;
788 panel
->sections
[CommandInfo
][0] = panel
->icommandL
;
789 panel
->sections
[CommandInfo
][1] = panel
->shortF
;
791 panel
->sections
[ExternalInfo
][0] = panel
->pathF
;
793 panel
->sections
[PipeInfo
][0] = panel
->pipeF
;
795 panel
->sections
[DirectoryInfo
][0] = panel
->dpathF
;
796 panel
->sections
[DirectoryInfo
][1] = panel
->dcommandF
;
798 panel
->currentType
= NoInfo
;
805 pos
= WMGetViewScreenPosition(WMWidgetView(panel
->box
));
808 pos
.x
+= FRAME_WIDTH
+ 20;
813 pos
.y
= WMAX(pos
.y
- 100, 0);
816 WEditMenuShowAt(panel
->menu
, pos
.x
, pos
.y
);
820 static void freeItemData(ItemData
* data
)
822 #define CFREE(d) if (d) wfree(d)
825 switch (data
->type
) {
827 CFREE(data
->param
.command
.parameter
);
828 CFREE(data
->param
.command
.shortcut
);
832 CFREE(data
->param
.exec
.command
);
833 CFREE(data
->param
.exec
.shortcut
);
837 CFREE(data
->param
.pipe
.command
);
841 CFREE(data
->param
.external
.path
);
845 CFREE(data
->param
.directory
.command
);
846 CFREE(data
->param
.directory
.directory
);
857 static ItemData
*parseCommand(WMPropList
* item
)
859 ItemData
*data
= NEW(ItemData
);
861 char *command
= NULL
;
862 char *parameter
= NULL
;
863 char *shortcut
= NULL
;
866 p
= WMGetFromPLArray(item
, i
++);
867 command
= WMGetFromPLString(p
);
868 if (strcmp(command
, "SHORTCUT") == 0) {
869 p
= WMGetFromPLArray(item
, i
++);
870 shortcut
= WMGetFromPLString(p
);
871 p
= WMGetFromPLArray(item
, i
++);
872 command
= WMGetFromPLString(p
);
874 p
= WMGetFromPLArray(item
, i
++);
876 parameter
= WMGetFromPLString(p
);
878 if (strcmp(command
, "EXEC") == 0 || strcmp(command
, "SHEXEC") == 0) {
880 data
->type
= ExecInfo
;
882 data
->param
.exec
.command
= wstrdup(parameter
);
884 data
->param
.exec
.shortcut
= wstrdup(shortcut
);
886 } else if (strcmp(command
, "OPEN_MENU") == 0) {
889 * dir menu, menu file
894 while (isspace(*p
) && *p
)
897 if (*(p
+ 1) == '|') {
899 data
->param
.pipe
.cached
= 0;
901 data
->param
.pipe
.cached
= 1;
903 data
->type
= PipeInfo
;
904 data
->param
.pipe
.command
= wtrimspace(p
+ 1);
910 s
= strstr(p
, "WITH");
917 data
->type
= DirectoryInfo
;
921 while (*s
&& isspace(*s
))
923 data
->param
.directory
.command
= wstrdup(s
);
925 wtokensplit(p
, &tokens
, &tokn
);
928 ctokens
= wmalloc(sizeof(char *) * tokn
);
930 for (i
= 0, j
= 0; i
< tokn
; i
++) {
931 if (strcmp(tokens
[i
], "-noext") == 0) {
932 data
->param
.directory
.stripExt
= 1;
934 ctokens
[j
++] = tokens
[i
];
937 data
->param
.directory
.directory
= wtokenjoin(ctokens
, j
);
940 wtokenfree(tokens
, tokn
);
942 data
->type
= ExternalInfo
;
943 data
->param
.external
.path
= p
;
946 } else if (strcmp(command
, "WORKSPACE_MENU") == 0) {
947 data
->type
= WSMenuInfo
;
948 } else if (strcmp(command
, "WINDOWS_MENU") == 0) {
949 data
->type
= WWindowListInfo
;
953 if (strcmp(command
, "ARRANGE_ICONS") == 0) {
955 } else if (strcmp(command
, "HIDE_OTHERS") == 0) {
957 } else if (strcmp(command
, "SHOW_ALL") == 0) {
959 } else if (strcmp(command
, "EXIT") == 0) {
961 } else if (strcmp(command
, "SHUTDOWN") == 0) {
963 } else if (strcmp(command
, "RESTART") == 0) {
969 } else if (strcmp(command
, "SAVE_SESSION") == 0) {
971 } else if (strcmp(command
, "CLEAR_SESSION") == 0) {
973 } else if (strcmp(command
, "REFRESH") == 0) {
975 } else if (strcmp(command
, "INFO_PANEL") == 0) {
977 } else if (strcmp(command
, "LEGAL_PANEL") == 0) {
980 wwarning(_("unknown command '%s' in menu"), command
);
985 data
->type
= CommandInfo
;
987 data
->param
.command
.command
= cmd
;
989 data
->param
.command
.shortcut
= wstrdup(shortcut
);
991 data
->param
.command
.parameter
= wstrdup(parameter
);
997 static void updateFrameTitle(_Panel
* panel
, char *title
, InfoType type
)
999 if (type
!= NoInfo
) {
1004 tmp
= wstrconcat(title
, _(": Execute Program"));
1008 tmp
= wstrconcat(title
, _(": Perform Internal Command"));
1012 tmp
= wstrconcat(title
, _(": Open a Submenu"));
1016 tmp
= wstrconcat(title
, _(": Program Generated Submenu"));
1020 tmp
= wstrconcat(title
, _(": Directory Contents Menu"));
1024 tmp
= wstrconcat(title
, _(": Open Workspaces Submenu"));
1027 case WWindowListInfo
:
1028 tmp
= wstrconcat(title
, _(": Open Window List Submenu"));
1035 WMSetFrameTitle(panel
->optionsF
, tmp
);
1038 WMSetFrameTitle(panel
->optionsF
, NULL
);
1042 static void changeInfoType(_Panel
* panel
, char *title
, InfoType type
)
1046 if (panel
->currentType
!= type
) {
1048 w
= panel
->sections
[panel
->currentType
];
1054 WMUnmapWidget(panel
->paramF
);
1055 WMUnmapWidget(panel
->quickB
);
1057 w
= panel
->sections
[type
];
1065 updateFrameTitle(panel
, title
, type
);
1067 panel
->currentType
= type
;
1070 static void updateMenuItem(_Panel
* panel
, WEditMenuItem
* item
, WMWidget
* changedWidget
)
1072 ItemData
*data
= WGetEditMenuItemData(item
);
1074 assert(data
!= NULL
);
1076 #define REPLACE(v, d) if (v) wfree(v); v = d
1078 switch (data
->type
) {
1080 if (changedWidget
== panel
->commandT
) {
1081 REPLACE(data
->param
.exec
.command
, WMGetTextFieldText(panel
->commandT
));
1083 if (changedWidget
== panel
->shortT
) {
1084 REPLACE(data
->param
.exec
.shortcut
, WMGetTextFieldText(panel
->shortT
));
1089 if (changedWidget
== panel
->icommandL
) {
1090 data
->param
.command
.command
= WMGetListSelectedItemRow(panel
->icommandL
);
1092 switch (data
->param
.command
.command
) {
1095 if (changedWidget
== panel
->quickB
) {
1096 REPLACE(data
->param
.command
.parameter
, WMGetButtonSelected(panel
->quickB
)
1097 ? wstrdup("QUICK") : NULL
);
1102 if (changedWidget
== panel
->paramT
) {
1103 REPLACE(data
->param
.command
.parameter
, WMGetTextFieldText(panel
->paramT
));
1107 if (changedWidget
== panel
->shortT
) {
1108 REPLACE(data
->param
.command
.shortcut
, WMGetTextFieldText(panel
->shortT
));
1114 if (changedWidget
== panel
->pipeT
) {
1115 REPLACE(data
->param
.pipe
.command
, WMGetTextFieldText(panel
->pipeT
));
1117 if (changedWidget
== panel
->pipeCacheB
) {
1118 data
->param
.pipe
.cached
= WMGetButtonSelected(panel
->pipeCacheB
);
1123 if (changedWidget
== panel
->pathT
) {
1124 REPLACE(data
->param
.external
.path
, WMGetTextFieldText(panel
->pathT
));
1129 if (changedWidget
== panel
->dpathT
) {
1130 REPLACE(data
->param
.directory
.directory
, WMGetTextFieldText(panel
->dpathT
));
1132 if (changedWidget
== panel
->dcommandT
) {
1133 REPLACE(data
->param
.directory
.command
, WMGetTextFieldText(panel
->dcommandT
));
1135 if (changedWidget
== panel
->dstripB
) {
1136 data
->param
.directory
.stripExt
= WMGetButtonSelected(panel
->dstripB
);
1149 menuItemCloned(WEditMenuDelegate
* delegate
, WEditMenu
* menu
, WEditMenuItem
* origItem
, WEditMenuItem
* newItem
)
1151 ItemData
*data
= WGetEditMenuItemData(origItem
);
1157 #define DUP(s) (s) ? wstrdup(s) : NULL
1159 newData
= NEW(ItemData
);
1161 newData
->type
= data
->type
;
1163 switch (data
->type
) {
1165 newData
->param
.exec
.command
= DUP(data
->param
.exec
.command
);
1166 newData
->param
.exec
.shortcut
= DUP(data
->param
.exec
.shortcut
);
1170 newData
->param
.command
.command
= data
->param
.command
.command
;
1171 newData
->param
.command
.parameter
= DUP(data
->param
.command
.parameter
);
1172 newData
->param
.command
.shortcut
= DUP(data
->param
.command
.shortcut
);
1176 newData
->param
.pipe
.command
= DUP(data
->param
.pipe
.command
);
1177 newData
->param
.pipe
.cached
= data
->param
.pipe
.cached
;
1181 newData
->param
.external
.path
= DUP(data
->param
.external
.path
);
1185 newData
->param
.directory
.directory
= DUP(data
->param
.directory
.directory
);
1186 newData
->param
.directory
.command
= DUP(data
->param
.directory
.command
);
1187 newData
->param
.directory
.stripExt
= data
->param
.directory
.stripExt
;
1196 WSetEditMenuItemData(newItem
, newData
, (WMCallback
*) freeItemData
);
1199 static void menuItemEdited(struct WEditMenuDelegate
*delegate
, WEditMenu
* menu
, WEditMenuItem
* item
)
1201 _Panel
*panel
= (_Panel
*) delegate
->data
;
1204 updateFrameTitle(panel
, WGetEditMenuItemTitle(item
), panel
->currentType
);
1206 submenu
= WGetEditMenuSubmenu(menu
, item
);
1208 WSetEditMenuTitle(submenu
, WGetEditMenuItemTitle(item
));
1212 static Bool
shouldRemoveItem(struct WEditMenuDelegate
*delegate
, WEditMenu
* menu
, WEditMenuItem
* item
)
1214 _Panel
*panel
= (_Panel
*) delegate
->data
;
1219 if (WGetEditMenuSubmenu(menu
, item
)) {
1222 res
= WMRunAlertPanel(WMWidgetScreen(menu
), NULL
,
1223 _("Remove Submenu"),
1224 _("Removing this item will destroy all items inside\n"
1225 "the submenu. Do you really want to do that?"),
1226 _("Yes"), _("No"), _("Yes, don't ask again."));
1233 panel
->dontAsk
= True
;
1240 static void menuItemDeselected(WEditMenuDelegate
* delegate
, WEditMenu
* menu
, WEditMenuItem
* item
)
1242 _Panel
*panel
= (_Panel
*) delegate
->data
;
1244 changeInfoType(panel
, NULL
, NoInfo
);
1247 static void menuItemSelected(WEditMenuDelegate
* delegate
, WEditMenu
* menu
, WEditMenuItem
* item
)
1249 ItemData
*data
= WGetEditMenuItemData(item
);
1250 _Panel
*panel
= (_Panel
*) delegate
->data
;
1252 panel
->currentItem
= item
;
1255 changeInfoType(panel
, WGetEditMenuItemTitle(item
), data
->type
);
1257 switch (data
->type
) {
1262 WMSetTextFieldText(panel
->commandT
, data
->param
.exec
.command
);
1263 WMSetTextFieldText(panel
->shortT
, data
->param
.exec
.shortcut
);
1267 WMSelectListItem(panel
->icommandL
, data
->param
.command
.command
);
1268 WMSetListPosition(panel
->icommandL
, data
->param
.command
.command
- 2);
1269 WMSetTextFieldText(panel
->shortT
, data
->param
.command
.shortcut
);
1271 switch (data
->param
.command
.command
) {
1274 WMSetButtonSelected(panel
->quickB
, data
->param
.command
.parameter
!= NULL
);
1277 WMSetTextFieldText(panel
->paramT
, data
->param
.command
.parameter
);
1281 icommandLClicked(panel
->icommandL
, panel
);
1285 WMSetTextFieldText(panel
->pipeT
, data
->param
.pipe
.command
);
1286 WMSetButtonSelected(panel
->pipeCacheB
, data
->param
.pipe
.cached
);
1290 WMSetTextFieldText(panel
->pathT
, data
->param
.external
.path
);
1294 WMSetTextFieldText(panel
->dpathT
, data
->param
.directory
.directory
);
1295 WMSetTextFieldText(panel
->dcommandT
, data
->param
.directory
.command
);
1296 WMSetButtonSelected(panel
->dstripB
, data
->param
.directory
.stripExt
);
1308 static WEditMenu
*buildSubmenu(_Panel
* panel
, WMPropList
* pl
)
1310 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
1312 WEditMenuItem
*item
;
1314 WMPropList
*tp
, *bp
;
1317 tp
= WMGetFromPLArray(pl
, 0);
1318 title
= WMGetFromPLString(tp
);
1320 menu
= WCreateEditMenu(scr
, title
);
1322 for (i
= 1; i
< WMGetPropListItemCount(pl
); i
++) {
1325 pi
= WMGetFromPLArray(pl
, i
);
1327 tp
= WMGetFromPLArray(pi
, 0);
1328 bp
= WMGetFromPLArray(pi
, 1);
1330 title
= WMGetFromPLString(tp
);
1332 if (!bp
|| WMIsPLArray(bp
)) { /* it's a submenu */
1335 submenu
= buildSubmenu(panel
, pi
);
1337 item
= WAddMenuItemWithTitle(menu
, title
);
1339 WSetEditMenuSubmenu(menu
, item
, submenu
);
1343 data
= parseCommand(pi
);
1346 item
= WAddMenuItemWithTitle(menu
, title
);
1347 if (panel
->markerPix
[data
->type
])
1348 WSetEditMenuItemImage(item
, panel
->markerPix
[data
->type
]);
1349 WSetEditMenuItemData(item
, data
, (WMCallback
*) freeItemData
);
1351 char *buf
= wmalloc(1024);
1352 snprintf(buf
, 1024, _("Invalid menu command \"%s\" with label \"%s\" cleared"),
1353 WMGetFromPLString(WMGetFromPLArray(pi
, 1)),
1354 WMGetFromPLString(WMGetFromPLArray(pi
, 0)));
1355 WMRunAlertPanel(scr
, panel
->parent
, _("Warning"), buf
, _("OK"), NULL
, NULL
);
1362 WSetEditMenuAcceptsDrop(menu
, True
);
1363 WSetEditMenuDelegate(menu
, &menuDelegate
);
1365 WMRealizeWidget(menu
);
1370 static void buildMenuFromPL(_Panel
* panel
, WMPropList
* pl
)
1372 panel
->menu
= buildSubmenu(panel
, pl
);
1375 static WMPropList
*getDefaultMenu(_Panel
* panel
)
1378 char *menuPath
, *gspath
;
1380 gspath
= wstrdup(WMAKER_RESOURCE_PATH
);
1382 menuPath
= wmalloc(strlen(gspath
) + 128);
1383 sprintf(menuPath
, "%s/plmenu", gspath
);
1385 menu
= WMReadPropListFromFile(menuPath
);
1390 msg
= _("Could not open default menu from '%s'");
1391 buffer
= wmalloc(strlen(msg
) + strlen(menuPath
) + 10);
1392 sprintf(buffer
, msg
, menuPath
);
1393 WMRunAlertPanel(WMWidgetScreen(panel
->parent
), panel
->parent
,
1394 _("Error"), buffer
, _("OK"), NULL
, NULL
);
1404 static void showData(_Panel
* panel
)
1410 gspath
= wusergnusteppath();
1412 menuPath
= wmalloc(strlen(gspath
) + 32);
1413 strcpy(menuPath
, gspath
);
1414 strcat(menuPath
, "/Defaults/WMRootMenu");
1416 pmenu
= WMReadPropListFromFile(menuPath
);
1418 if (!pmenu
|| !WMIsPLArray(pmenu
)) {
1421 res
= WMRunAlertPanel(WMWidgetScreen(panel
->parent
), panel
->parent
,
1423 _("The menu file format currently in use is not supported\n"
1424 "by this tool. Do you want to discard the current menu\n"
1425 "to use this tool?"),
1426 _("Yes, Discard and Update"), _("No, Keep Current Menu"), NULL
);
1428 if (res
== WAPRDefault
) {
1429 pmenu
= getDefaultMenu(panel
);
1432 pmenu
= WMCreatePLArray(WMCreatePLString("Applications"), NULL
);
1435 panel
->dontSave
= True
;
1440 panel
->menuPath
= menuPath
;
1442 buildMenuFromPL(panel
, pmenu
);
1444 WMReleasePropList(pmenu
);
1447 static Bool
notblank(char *s
)
1458 static WMPropList
*processData(char *title
, ItemData
* data
)
1462 static WMPropList
*pscut
= NULL
;
1463 static WMPropList
*pomenu
= NULL
;
1470 pscut
= WMCreatePLString("SHORTCUT");
1471 pomenu
= WMCreatePLString("OPEN_MENU");
1474 item
= WMCreatePLArray(WMCreatePLString(title
), NULL
);
1476 switch (data
->type
) {
1478 if (data
->param
.exec
.command
== NULL
)
1481 if (strpbrk(data
->param
.exec
.command
, "&$*|><?`=;")) {
1490 if (notblank(data
->param
.exec
.shortcut
)) {
1491 WMAddToPLArray(item
, pscut
);
1492 WMAddToPLArray(item
, WMCreatePLString(data
->param
.exec
.shortcut
));
1495 WMAddToPLArray(item
, WMCreatePLString(s1
));
1496 WMAddToPLArray(item
, WMCreatePLString(data
->param
.exec
.command
));
1500 if (notblank(data
->param
.command
.shortcut
)) {
1501 WMAddToPLArray(item
, pscut
);
1502 WMAddToPLArray(item
, WMCreatePLString(data
->param
.command
.shortcut
));
1505 i
= data
->param
.command
.command
;
1507 WMAddToPLArray(item
, WMCreatePLString(commandNames
[i
]));
1512 if (data
->param
.command
.parameter
) {
1513 WMAddToPLArray(item
, WMCreatePLString(data
->param
.command
.parameter
));
1517 case 6: /* restart */
1518 if (data
->param
.command
.parameter
) {
1519 WMAddToPLArray(item
, WMCreatePLString(data
->param
.command
.parameter
));
1527 if (!data
->param
.pipe
.command
)
1529 WMAddToPLArray(item
, pomenu
);
1530 if (data
->param
.pipe
.cached
)
1531 s1
= wstrconcat("| ", data
->param
.pipe
.command
);
1533 s1
= wstrconcat("|| ", data
->param
.pipe
.command
);
1534 WMAddToPLArray(item
, WMCreatePLString(s1
));
1539 if (!data
->param
.external
.path
)
1541 WMAddToPLArray(item
, pomenu
);
1542 WMAddToPLArray(item
, WMCreatePLString(data
->param
.external
.path
));
1546 if (!data
->param
.directory
.directory
|| !data
->param
.directory
.command
)
1552 l
= strlen(data
->param
.directory
.directory
);
1553 l
+= strlen(data
->param
.directory
.command
);
1556 WMAddToPLArray(item
, pomenu
);
1559 sprintf(tmp
, "%s%s WITH %s",
1560 data
->param
.directory
.stripExt
? "-noext " : "",
1561 data
->param
.directory
.directory
, data
->param
.directory
.command
);
1563 WMAddToPLArray(item
, WMCreatePLString(tmp
));
1569 WMAddToPLArray(item
, WMCreatePLString("WORKSPACE_MENU"));
1572 case WWindowListInfo
:
1573 WMAddToPLArray(item
, WMCreatePLString("WINDOWS_MENU"));
1584 static WMPropList
*processSubmenu(WEditMenu
* menu
)
1586 WEditMenuItem
*item
;
1592 s
= WGetEditMenuTitle(menu
);
1593 pl
= WMCreatePLString(s
);
1595 pmenu
= WMCreatePLArray(pl
, NULL
);
1598 while ((item
= WGetEditMenuItem(menu
, i
++))) {
1601 s
= WGetEditMenuItemTitle(item
);
1603 submenu
= WGetEditMenuSubmenu(menu
, item
);
1605 pl
= processSubmenu(submenu
);
1607 pl
= processData(s
, WGetEditMenuItemData(item
));
1613 WMAddToPLArray(pmenu
, pl
);
1619 static WMPropList
*buildPLFromMenu(_Panel
* panel
)
1623 menu
= processSubmenu(panel
->menu
);
1628 static void storeData(_Panel
* panel
)
1632 if (panel
->dontSave
)
1635 menu
= buildPLFromMenu(panel
);
1637 WMWritePropListToFile(menu
, panel
->menuPath
);
1639 WMReleasePropList(menu
);
1642 static void showMenus(_Panel
* panel
)
1645 WEditMenuUnhide(panel
->menu
);
1648 static void hideMenus(_Panel
* panel
)
1651 WEditMenuHide(panel
->menu
);
1654 Panel
*InitMenu(WMScreen
* scr
, WMWidget
* parent
)
1658 panel
= wmalloc(sizeof(_Panel
));
1659 memset(panel
, 0, sizeof(_Panel
));
1661 panel
->sectionName
= _("Applications Menu Definition");
1663 panel
->description
= _("Edit the menu for launching applications.");
1665 panel
->parent
= parent
;
1667 panel
->callbacks
.createWidgets
= createPanel
;
1668 panel
->callbacks
.updateDomain
= storeData
;
1669 panel
->callbacks
.showPanel
= showMenus
;
1670 panel
->callbacks
.hidePanel
= hideMenus
;
1672 AddSection(panel
, ICON_FILE
);