From 294b0f10829bd3c6fec0f5b50ccd451ecd076be1 Mon Sep 17 00:00:00 2001
From: Andreas Bierfert <[email protected]>
Date: Sun, 27 Jan 2013 17:11:38 +0100
Subject: [PATCH 2/2] Use same parsing code for generated and external submenus
This patch changes the behavior of generated menues to use the same parsing
code for proplists (getPropList) as the extern submenu does. This way a call
to 'wmmenugen > file' gives the same result as adding that call to a generated
submenu.
---
src/rootmenu.c | 44 ++++++++------------------------------------
1 file changed, 8 insertions(+), 36 deletions(-)
diff --git a/src/rootmenu.c b/src/rootmenu.c
index 2fcd0ae..422b2dd 100644
--- a/src/rootmenu.c
+++ b/src/rootmenu.c
@@ -982,10 +982,8 @@ static WMenu *readMenuFile(WScreen * scr, char *file_name)
static WMenu *readMenuPipe(WScreen * scr, char **file_name)
{
+ WMPropList *plist = NULL;
WMenu *menu = NULL;
- FILE *file = NULL;
- WMenuParser parser;
- char *command, *params, *shortcut, *title;
char *filename;
char flat_file[MAXLINE];
int i;
@@ -998,42 +996,16 @@ static WMenu *readMenuPipe(WScreen * scr, char
**file_name)
}
filename = flat_file + (flat_file[1] == '|' ? 2 : 1);
- file = popen(filename, "r");
- if (!file) {
- werror(_("%s:could not open menu file"), filename);
- return NULL;
- }
- parser = WMenuParserCreate(flat_file, file, DEF_CONFIG_PATHS);
- menu_parser_register_macros(parser);
-
- while (WMenuParserGetLine(parser, &title, &command, ¶ms,
&shortcut)) {
-
- if (command == NULL || !command[0]) {
- WMenuParserError(parser, _("missing command in menu
config") );
- freeline(title, command, params, shortcut);
- break;
- }
- if (strcasecmp(command, "MENU") == 0) {
- menu = wMenuCreate(scr, M_(title), True);
- menu->on_destroy = removeShortcutsForMenu;
- if (!parseCascade(scr, menu, parser)) {
- wMenuDestroy(menu, True);
- menu = NULL;
- }
- freeline(title, command, params, shortcut);
- break;
- } else {
- WMenuParserError(parser, _("no title given for the root
menu") );
- freeline(title, command, params, shortcut);
- break;
- }
+ plist = WMReadPropListFromPipe(filename);
- freeline(title, command, params, shortcut);
- }
+ if(!plist)
+ return NULL;
- WMenuParserDelete(parser);
- pclose(file);
+ menu = configureMenu(scr, plist, False);
+ if(!menu)
+ return NULL;
+ menu->on_destroy = removeShortcutsForMenu;
return menu;
}
--
1.8.1
--
To unsubscribe, send mail to [email protected].