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
This commit is contained in:
Jee-Yong Um 2014-12-18 16:08:34 +09:00 committed by Carsten Haitzler (Rasterman)
parent 837fb90c4e
commit 7a1c6c0725
1 changed files with 36 additions and 12 deletions

View File

@ -1959,20 +1959,44 @@ 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);
elm_win_center(dia->win, 1, 1);
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");