raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=7a1c6c07259e5e73a1d223346485a966a4cbdf5e

commit 7a1c6c07259e5e73a1d223346485a966a4cbdf5e
Author: Jee-Yong Um <jc9...@samsung.com>
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 | 48 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 12 deletions(-)

diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c
index 6f89aac..98b9c76 100644
--- a/src/bin/e_actions.c
+++ b/src/bin/e_actions.c
@@ -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");

-- 


Reply via email to