[alacarte] Fix Python error on startup with gnome-menus 2.91.6+



commit 8c33986006604f4fa308c439466f7de9b5c9227a
Author: Josselin Mouette <joss debian org>
Date:   Mon Aug 22 20:47:47 2011 +0200

    Fix Python error on startup with gnome-menus 2.91.6+

 Alacarte/MainWindow.py |    1 -
 Alacarte/MenuEditor.py |   45 ++++++---------------------------------------
 2 files changed, 6 insertions(+), 40 deletions(-)
---
diff --git a/Alacarte/MainWindow.py b/Alacarte/MainWindow.py
index f5d655f..0d31043 100644
--- a/Alacarte/MainWindow.py
+++ b/Alacarte/MainWindow.py
@@ -74,7 +74,6 @@ class MainWindow:
 	def run(self):
 		self.loadMenus()
 		self.editor.applications.tree.add_monitor(self.menuChanged, None)
-		self.editor.settings.tree.add_monitor(self.menuChanged, None)
 		self.tree.get_object('mainwindow').show_all()
 		Gtk.main()
 
diff --git a/Alacarte/MenuEditor.py b/Alacarte/MenuEditor.py
index a160e33..fafd87e 100644
--- a/Alacarte/MenuEditor.py
+++ b/Alacarte/MenuEditor.py
@@ -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



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