Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        menus-misc.c menus.c 


Log Message:
Prepare to move menus in menus.cfg to simple files - continued.

===================================================================
RCS file: /cvs/e/e16/e/src/menus-misc.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -3 -r1.44 -r1.45
--- menus-misc.c        2 Jun 2007 10:01:34 -0000       1.44
+++ menus-misc.c        3 Jun 2007 11:55:29 -0000       1.45
@@ -311,16 +311,20 @@
 
        if (first)
          {
-            char               *title;
+            char               *title, *style, *alias;
 
             first = 0;
 
-            title = NULL;
-            parse(s, "%S", &title);
+            title = style = alias = NULL;
+            parse(s, "%S%S%S", &title, &style, &alias);
 
-            if (!title)
-               continue;
-            MenuSetTitle(m, title);
+            if (title)
+               MenuSetTitle(m, title);
+            if (!style)
+               style = (char *)"ROOT";
+            MenuSetStyle(m, MenuStyleFind(style));
+            if (alias)
+               MenuSetAlias(m, alias);
          }
        else
          {
===================================================================
RCS file: /cvs/e/e16/e/src/menus.c,v
retrieving revision 1.277
retrieving revision 1.278
diff -u -3 -r1.277 -r1.278
--- menus.c     2 Jun 2007 10:01:34 -0000       1.277
+++ menus.c     3 Jun 2007 11:55:29 -0000       1.278
@@ -278,7 +278,7 @@
    int                 w, h, mw, mh;   /* from appearing offscreen */
    int                 head_num = 0;
 
-   if (m->shown || !m->style)
+   if (m->shown)
       return;
 
    if (MenuLoad(m))
@@ -290,6 +290,9 @@
    if (!m->win)
       MenuRealize(m);
 
+   if (!m->style)
+      return;
+
    ewin = m->ewin;
    if (ewin)
      {
@@ -546,7 +549,8 @@
    m->parent = parent;
    MenuSetName(m, name);
    MenuSetTitle(m, title);
-   MenuSetStyle(m, ms);
+   if (ms)
+      MenuSetStyle(m, ms);
    m->icon_size = -1;          /* Use image size */
 
    if (!menu_list)
@@ -687,7 +691,11 @@
    char                has_i, has_s;
 
    if (!m->style)
-      return;
+     {
+       MenuSetStyle(m, NULL);
+       if (!m->style)
+          return;
+     }
 
    if (!m->win)
      {
@@ -716,7 +724,7 @@
        ESelectInput(m->items[i]->win, MENU_ITEM_EVENT_MASK);
        EMapWindow(m->items[i]->win);
 
-       if ((m->style) && (m->style->tclass) && (m->items[i]->text))
+       if ((m->style->tclass) && (m->items[i]->text))
          {
             TextSize(m->style->tclass, 0, 0, 0, _(m->items[i]->text), &w, &h,
                      17);
@@ -1832,6 +1840,33 @@
    return err;
 }
 
+/*
+ * Aliases for "well-known" menus for backward compatibility.
+ */
+static const char  *const menu_aliases[] = {
+   "APPS_SUBMENU", "file.menu",
+   "CONFIG_SUBMENU", "settings.menu",
+   "DESKTOP_SUBMENU", "desktop.menu",
+   "MAINT_SUBMENU", "maintenance.menu",
+   "ROOT_2", "enlightenment.menu",
+   "WINOPS_MENU", "winops.menu",
+};
+#define N_MENU_ALIASES (sizeof(menu_aliases)/sizeof(char*)/2)
+
+static void
+_MenuCheckAlias(Menu * m)
+{
+   unsigned int        i;
+
+   for (i = 0; i < N_MENU_ALIASES; i++)
+     {
+       if (strcmp(m->name, menu_aliases[2 * i]))
+          continue;
+       MenuSetAlias(m, menu_aliases[2 * i + 1]);
+       break;
+     }
+}
+
 int
 MenuConfigLoad(FILE * fs)
 {
@@ -1898,6 +1933,7 @@
                m = MenuCreate(s2, NULL, NULL, NULL);
             else
                MenuSetName(m, s2);
+            _MenuCheckAlias(m);
             break;
          case MENU_USE_STYLE:
             MenuSetStyle(m, MenuStyleFind(s2));
@@ -2113,8 +2149,10 @@
    else if (!strncmp(cmd, "list", 2))
      {
 #define SS(s) ((s) ? (s) : "-")
+#define ST(s) ((s) ? (s->name) : "-")
        ECORE_LIST_FOR_EACH(menu_list, m)
-          IpcPrintf("%s(%s): %s\n", m->name, SS(m->alias), SS(m->title));
+          IpcPrintf("%s(%s/%s): %s\n", m->name, SS(m->alias), ST(m->style),
+                    SS(m->title));
      }
    else if (!strncmp(cmd, "reload", 2))
      {



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to