Enlightenment CVS committal

Author  : onefang
Project : e_modules
Module  : emu

Dir     : e_modules/emu/src/modules/emu


Modified Files:
        border_props.c e_mod_main.c 


Log Message:
Actually make the substitution of the border data for border menus.

===================================================================
RCS file: /cvsroot/enlightenment/e_modules/emu/src/modules/emu/border_props.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- border_props.c      5 Feb 2006 04:39:40 -0000       1.1
+++ border_props.c      5 Feb 2006 06:33:20 -0000       1.2
@@ -59,6 +59,7 @@
 EAPI char *
 border_props_substitute(E_Border * bd, char type)
 {
+   int found = 1;
    char buf[32];
    char *result = NULL;
 
@@ -119,10 +120,16 @@
      case 'z':
         result = bd->zone->name;
         break;
+     default :
+        found = 0;
+       break;
      }
    if (!result)
       result = buf;
-   return strdup(result);
+   if (found)
+      return strdup(result);
+   else
+      return NULL;
 }
 
 static void
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/emu/src/modules/emu/e_mod_main.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- e_mod_main.c        5 Feb 2006 04:39:40 -0000       1.7
+++ e_mod_main.c        5 Feb 2006 06:33:20 -0000       1.8
@@ -995,8 +995,8 @@
         char *action;
 
         exe = item->data;
-        action = item->action;
-        if (item->easy_menu->category_data)
+        action = strdup(item->action);
+        if ((action) && (item->easy_menu->category_data))
           {
              /* Check the category, if its border or fileman, do some % subs 
on action. */
              if ((item->easy_menu->category) && 
(strncmp(item->easy_menu->category, "border", 6) == 0))
@@ -1006,12 +1006,55 @@
                   bd = item->easy_menu->category_data;
                   if (strcmp(action, "Properties") == 0)
                     {
-                       action = NULL;
+                       E_FREE(action);
                        border_props_dialog(m->zone->container, bd);
                     }
                   else
                     {
+                      char *buffer = NULL, *c;
+                      int length, i = 0;
+
                        /* Do some % subs on action. */
+                      length = (strlen(action) * 2) + 1;
+                      buffer = realloc(buffer, length);
+                      for (c = action; (*c) != '\0'; c++)
+                         {
+                            if ((*c) == '%')
+                               {
+                                   char *sub;
+
+                                  c++;
+                                   sub = border_props_substitute(bd, 
+                                                                (*c));  // 
Fucked if I know why the compiler bitchs about this.
+                                  if (sub)
+                                     {
+                                        int len;
+
+                                         len = strlen(sub);
+                                        if ((i + len + 1) > length)
+                                           {
+                                              length *= 2;
+                                              length += len + 1;
+                                              buffer = realloc(buffer, length);
+                                           }
+                                        memcpy(&buffer[i], sub, len + 1);
+                                        i += len;
+                                        continue;
+                                     }
+                                     if ((*c) == '\0')
+                                        break;
+                               }
+                               if (i > length)
+                                  {
+                                     length *= 2;
+                                     buffer = realloc(buffer, length);
+                                  }
+                               buffer[i++] = (*c);
+                         }
+                      buffer[i++] = '\0';
+                       printf("\n_emu_menu_cb_action() -> 
\n%s\nbecame\n%s\n\n", action, buffer);
+                       E_FREE(action);
+                      action = buffer;
                     }
                }
              else if ((item->easy_menu->category) && 
(strncmp(item->easy_menu->category, "fileman/action", 14) == 0))
@@ -1029,10 +1072,10 @@
           }
         if ((action) && (action[0] != '\0'))
           {
-             printf("_emu_menu_cb_action() -> %s\n", action);
              ecore_exe_send(exe, action, strlen(action));
              ecore_exe_send(exe, "\n", 1);
           }
+        E_FREE(action);
      }
 }
 




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to