Code

r10818@tres: ted | 2006-01-29 16:08:07 -0800
authorgouldtj <gouldtj@users.sourceforge.net>
Mon, 30 Jan 2006 05:12:10 +0000 (05:12 +0000)
committergouldtj <gouldtj@users.sourceforge.net>
Mon, 30 Jan 2006 05:12:10 +0000 (05:12 +0000)
 Whoo hoo, we do submenus now too!

src/extension/effect.cpp

index 1d0c4c4af4757bb31063a5437eccf90c5b0157e5..f88833ec445c9a545726ac362bdf4dca0b6da268 100644 (file)
@@ -68,6 +68,7 @@ Effect::merge_menu (Inkscape::XML::Node * base,
                     Inkscape::XML::Node * mergee) {
     Glib::ustring mergename;
     Inkscape::XML::Node * tomerge = NULL;
+    Inkscape::XML::Node * submenu = NULL;
 
     /* printf("Merge menu with '%s' '%s' '%s'\n",
             base != NULL ? base->name() : "NULL",
@@ -89,8 +90,7 @@ Effect::merge_menu (Inkscape::XML::Node * base,
         mergename = _(menuname);
     }
 
-    base->appendChild(tomerge);
-    Inkscape::GC::release(tomerge);
+    int position = -1;
 
     if (start != NULL) {
         Inkscape::XML::Node * menupass;
@@ -116,15 +116,31 @@ Effect::merge_menu (Inkscape::XML::Node * base,
 
             Glib::ustring compare(_(compare_char));
 
+            if (mergename == compare) {
+                Inkscape::GC::release(tomerge);
+                tomerge = NULL;
+                submenu = menupass;
+                break;
+            }
+
             if (mergename < compare) {
-                tomerge->setPosition(menupass->position());
+                position = menupass->position();
                 break;
             }
         } // for menu items
     } // start != NULL
 
+    if (tomerge != NULL) {
+        base->appendChild(tomerge);
+        Inkscape::GC::release(tomerge);
+        if (position != -1)
+            tomerge->setPosition(position);
+    }
+
     if (patern != NULL) {
-        merge_menu(tomerge, tomerge->firstChild(), patern->firstChild(), mergee);
+        if (submenu == NULL)
+            submenu = tomerge;
+        merge_menu(submenu, submenu->firstChild(), patern->firstChild(), mergee);
     }
 
     return;