[alacarte] MenuEditor: Remove unused code of moving menus/things between menus



commit 7d1a28d059e60791f9084bf2b13c991b43d4aad3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jun 20 15:05:14 2012 -0400

    MenuEditor: Remove unused code of moving menus/things between menus
    
    We can always revive it if it gets used again.

 Alacarte/MainWindow.py |   14 ++------------
 Alacarte/MenuEditor.py |   44 ++++----------------------------------------
 2 files changed, 6 insertions(+), 52 deletions(-)
---
diff --git a/Alacarte/MainWindow.py b/Alacarte/MainWindow.py
index 355a5a3..300649b 100644
--- a/Alacarte/MainWindow.py
+++ b/Alacarte/MainWindow.py
@@ -436,12 +436,7 @@ class MainWindow(object):
             return
         item = items[path][3]
         before = items[(path.get_indices()[0] - 1,)][3]
-        if isinstance(item, GMenu.TreeEntry):
-            self.editor.moveItem(item, item.get_parent(), before=before)
-        elif isinstance(item, GMenu.TreeDirectory):
-            self.editor.moveMenu(item, item.get_parent(), before=before)
-        elif isinstance(item, GMenu.TreeSeparator):
-            self.editor.moveSeparator(item, item.get_parent(), before=before)
+        self.editor.moveItem(item.get_parent(), item, before=before)
 
     def on_move_down_button_clicked(self, button):
         item_tree = self.tree.get_object('item_tree')
@@ -454,12 +449,7 @@ class MainWindow(object):
             return
         item = items[path][3]
         after = items[path][3]
-        if isinstance(item, GMenu.TreeEntry):
-            self.editor.moveItem(item, item.get_parent(), after=after)
-        elif isinstance(item, GMenu.TreeDirectory):
-            self.editor.moveMenu(item, item.get_parent(), after=after)
-        elif isinstance(item, GMenu.TreeSeparator):
-            self.editor.moveSeparator(item, item.get_parent(), after=after)
+        self.editor.moveItem(item.get_parent(), item, after=after)
 
     def on_help_button_clicked(self, *args):
         Gtk.show_uri(Gdk.Screen.get_default(), "ghelp:user-guide#menu-editor", Gtk.get_current_event_time())
diff --git a/Alacarte/MenuEditor.py b/Alacarte/MenuEditor.py
index f04dd20..a6fc152 100644
--- a/Alacarte/MenuEditor.py
+++ b/Alacarte/MenuEditor.py
@@ -266,46 +266,6 @@ class MenuEditor(object):
         self.save()
         return file_id
 
-    def moveItem(self, item, new_parent, before=None, after=None):
-        if item.get_parent() != new_parent:
-            #hide old item
-            self.deleteItem(item)
-            file_id = self.copyItem(item, new_parent)
-            item = ('Item', file_id)
-        self.positionItem(new_parent, item, before, after)
-        self.save()
-
-    def moveMenu(self, menu, new_parent, before=None, after=None):
-        parent = new_parent
-        #don't move a menu into it's child
-        while parent.get_parent():
-            parent = parent.get_parent()
-            if parent == menu:
-                return False
-
-        #don't move a menu into itself
-        if new_parent == menu:
-            return False
-
-        if menu.get_parent() != new_parent:
-            dom = self.dom
-            path = self.getPath(menu)
-            root_path = path[0]
-            xml_root = self.getXmlMenu(root_path, dom.documentElement, dom)
-            old_path = path[1:]
-            new_path = self.getPath(new_parent)[1:] + [menu.get_menu_id()]
-            self.addXmlMove(xml_root, '/'.join(old_path), '/'.join(new_path), dom)
-        self.positionItem(new_parent, menu, before, after)
-        self.save()
-
-    def moveSeparator(self, separator, new_parent, before=None, after=None):
-        # remove the original separator if its parent is not the new destination
-        if separator.get_parent() != new_parent:
-            self.deleteSeparator(separator)
-        # this adds the new separator to the specified position
-        self.positionItem(new_parent, separator, before, after)
-        self.save()
-
     def deleteItem(self, item):
         self.writeItem(item, Hidden=True)
         self.save()
@@ -531,6 +491,10 @@ class MenuEditor(object):
         xml_parent = self.getXmlMenu(self.getPath(parent), dom.documentElement, dom)
         self.addXmlFilename(xml_parent, dom, file_id, 'Include')
 
+    def moveItem(self, parent, item, before=None, after=None):
+        self.positionItem(parent, item, before=before, after=after)
+        self.save()
+
     def positionItem(self, parent, item, before=None, after=None):
         contents = self.getContents(parent)
         if after:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]