cedric pushed a commit to branch enlightenment-0.17. http://git.enlightenment.org/core/enlightenment.git/commit/?id=b2da7f0f700a80b57a6d454c034eff7c3c610a6d
commit b2da7f0f700a80b57a6d454c034eff7c3c610a6d Author: Jee-Yong Um <[email protected]> Date: Thu Dec 18 16:08:34 2014 +0900 e_actions: Fix to parse syntax correctly in key binding settings Summary: Correct the way to parse syntax in key bindings for launching application according to syntax guide and pop an error dialog when a space is detected while activating the action. Example: Guide is given like "exe:xterm" with "No whitespace" between param's name and contents. However, existing way to parse syntax should require "ONE whitespace" between name and contents. This modification will parse syntax correctly. @fix Reviewers: seoz, zmike, Hermet Subscribers: raster, cippp, cedric Differential Revision: https://phab.enlightenment.org/D1699 --- src/bin/e_actions.c | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c index 96d233c..b344ab6 100644 --- a/src/bin/e_actions.c +++ b/src/bin/e_actions.c @@ -2006,20 +2006,43 @@ ACT_FN_GO(app, ) Efreet_Desktop *desktop = NULL; char *p, *p2; - p2 = alloca(strlen(params) + 1); - strcpy(p2, params); - p = strchr(p2, ' '); + p2 = strdupa(params); + p = strchr(p2, ':'); if (p) { - *p = 0; - if (!strcmp(p2, "file:")) - desktop = efreet_util_desktop_file_id_find(p + 1); - else if (!strcmp(p2, "name:")) - desktop = efreet_util_desktop_name_find(p + 1); - else if (!strcmp(p2, "generic:")) - desktop = efreet_util_desktop_generic_name_find(p + 1); - else if (!strcmp(p2, "exe:")) - desktop = efreet_util_desktop_exec_find(p + 1); + *p++ = 0; + if (*p == ' ') + { + E_Dialog *dia; + char dialog_text[1024]; + + dia = e_dialog_new(NULL, "E", "_e_action_act_app_go_syntax_error"); + if (!dia) return; + + snprintf(dialog_text, sizeof(dialog_text), + "%s<br><br>" + "Check syntax. You should not put a whitespace right after colon in action params.<br>" + "syntax: [file:file.desktop|name:App Name|generic:Generic Name|exe:exename]<br><br>" + "exe:terminology (O)<br>" + "exe: terminology (X)", params); + + e_dialog_title_set(dia, _("Action Params Syntax Error")); + e_dialog_text_set(dia, _(dialog_text)); + e_dialog_icon_set(dia, "dialog-error", 64); + e_dialog_button_add(dia, _("Close"), NULL, NULL, NULL); + e_dialog_button_focus_num(dia, 0); + e_dialog_show(dia); + + return; + } + if (!strcmp(p2, "file")) + desktop = efreet_util_desktop_file_id_find(p); + else if (!strcmp(p2, "name")) + desktop = efreet_util_desktop_name_find(p); + else if (!strcmp(p2, "generic")) + desktop = efreet_util_desktop_generic_name_find(p); + else if (!strcmp(p2, "exe")) + desktop = efreet_util_desktop_exec_find(p); if (desktop) { e_exec(zone, desktop, NULL, NULL, "action/app"); --
