112 lines
4.2 KiB
Plaintext
112 lines
4.2 KiB
Plaintext
$OpenBSD: patch-Alacarte_MenuEditor_py,v 1.1 2011/09/13 07:20:37 ajacoutot Exp $
|
|
|
|
From 8c33986006604f4fa308c439466f7de9b5c9227a Mon Sep 17 00:00:00 2001
|
|
From: Josselin Mouette <joss@debian.org>
|
|
Date: Mon, 22 Aug 2011 18:47:47 +0000
|
|
Subject: Fix Python error on startup with gnome-menus 2.91.6+
|
|
|
|
--- Alacarte/MenuEditor.py.orig Tue Sep 8 12:04:27 2009
|
|
+++ Alacarte/MenuEditor.py Tue Sep 13 08:54:29 2011
|
|
@@ -48,22 +48,10 @@ class MenuEditor:
|
|
self.applications.dom = xml.dom.minidom.parse(self.applications.path)
|
|
self.__remove_whilespace_nodes(self.applications.dom)
|
|
|
|
- self.settings = Menu()
|
|
- self.settings.tree = gmenu.lookup_tree('settings.menu', gmenu.FLAGS_SHOW_EMPTY|gmenu.FLAGS_INCLUDE_EXCLUDED|gmenu.FLAGS_INCLUDE_NODISPLAY|gmenu.FLAGS_SHOW_ALL_SEPARATORS)
|
|
- self.settings.visible_tree = gmenu.lookup_tree('settings.menu')
|
|
- self.settings.tree.sort_key = gmenu.SORT_DISPLAY_NAME
|
|
- self.settings.visible_tree.sort_key = gmenu.SORT_DISPLAY_NAME
|
|
- self.settings.path = os.path.join(util.getUserMenuPath(), self.settings.tree.get_menu_file())
|
|
- if not os.path.isfile(self.settings.path):
|
|
- self.settings.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.settings.tree))
|
|
- else:
|
|
- self.settings.dom = xml.dom.minidom.parse(self.settings.path)
|
|
- self.__remove_whilespace_nodes(self.settings.dom)
|
|
-
|
|
self.save(True)
|
|
|
|
def save(self, from_loading=False):
|
|
- for menu in ('applications', 'settings'):
|
|
+ for menu in ('applications',):
|
|
fd = open(getattr(self, menu).path, 'w')
|
|
fd.write(re.sub("\n[\s]*([^\n<]*)\n[\s]*</", "\\1</", getattr(self, menu).dom.toprettyxml().replace('<?xml version="1.0" ?>\n', '')))
|
|
fd.close()
|
|
@@ -85,7 +73,7 @@ class MenuEditor:
|
|
os.unlink(file_path)
|
|
|
|
def revert(self):
|
|
- for name in ('applications', 'settings'):
|
|
+ for name in ('applications',):
|
|
menu = getattr(self, name)
|
|
self.revertTree(menu.tree.root)
|
|
path = os.path.join(util.getUserMenuPath(), menu.tree.get_menu_file())
|
|
@@ -126,7 +114,7 @@ class MenuEditor:
|
|
os.unlink(file_path)
|
|
redo.append(redo_path)
|
|
#reload DOM to make changes stick
|
|
- for name in ('applications', 'settings'):
|
|
+ for name in ('applications',):
|
|
menu = getattr(self, name)
|
|
if not os.path.isfile(menu.path):
|
|
menu.dom = xml.dom.minidom.parseString(util.getUserMenuXml(menu.tree))
|
|
@@ -150,7 +138,7 @@ class MenuEditor:
|
|
os.unlink(file_path)
|
|
undo.append(undo_path)
|
|
#reload DOM to make changes stick
|
|
- for name in ('applications', 'settings'):
|
|
+ for name in ('applications',):
|
|
menu = getattr(self, name)
|
|
if not os.path.isfile(menu.path):
|
|
menu.dom = xml.dom.minidom.parseString(util.getUserMenuXml(menu.tree))
|
|
@@ -162,7 +150,6 @@ class MenuEditor:
|
|
def getMenus(self, parent=None):
|
|
if parent == None:
|
|
yield self.applications.tree.root
|
|
- yield self.settings.tree.root
|
|
else:
|
|
for menu in parent.get_contents():
|
|
if menu.get_type() == gmenu.TYPE_DIRECTORY:
|
|
@@ -430,31 +417,13 @@ class MenuEditor:
|
|
self.__undo[-1].append(undo_path)
|
|
|
|
def __getMenu(self, item):
|
|
- root = item.get_parent()
|
|
- if not root:
|
|
- #already at the top
|
|
- root = item
|
|
- else:
|
|
- while True:
|
|
- if root.get_parent():
|
|
- root = root.get_parent()
|
|
- else:
|
|
- break
|
|
- if root.menu_id == self.applications.tree.root.menu_id:
|
|
- return self.applications
|
|
- return self.settings
|
|
+ return self.applications
|
|
|
|
def __findMenu(self, menu_id, parent=None):
|
|
if parent == None:
|
|
- menu = self.__findMenu(menu_id, self.applications.tree.root)
|
|
- if menu != None:
|
|
- return menu
|
|
- else:
|
|
- return self.__findMenu(menu_id, self.settings.tree.root)
|
|
+ return self.__findMenu(menu_id, self.applications.tree.root)
|
|
if menu_id == self.applications.tree.root.menu_id:
|
|
return self.applications.tree.root
|
|
- if menu_id == self.settings.tree.root.menu_id:
|
|
- return self.settings.tree.root
|
|
for item in parent.get_contents():
|
|
if item.get_type() == gmenu.TYPE_DIRECTORY:
|
|
if item.menu_id == menu_id:
|
|
@@ -469,8 +438,6 @@ class MenuEditor:
|
|
menu = self.__getMenu(item)
|
|
if menu == self.applications:
|
|
root = self.applications.visible_tree.root
|
|
- elif menu == self.settings:
|
|
- root = self.settings.visible_tree.root
|
|
if item.get_type() == gmenu.TYPE_DIRECTORY:
|
|
if self.__findMenu(item.menu_id, root) == None:
|
|
return False
|