Package: alacarte
Version: 0.12.4-1

--- Please enter the report below this line. ---

Hi,

alacarte currently uses a non-unique menu_id, when adding new items (or menus).

This causes any new item will be placed under the first menu with a matching id
(usually under the debian menu tree).
E.g. the menu id "graphics" is available as a top-level menu (visible in
the application menu) and as a lower-level menu (below the debian tree).

The attached patch fixes this by using the specific destination menu object
instead of its id.

The following bugs seem to be duplicates of this one and should be merged (I
don't know how to do it):
 - #444317
 - #461318

thanks for your work,
Lars

--- System information. ---
Architecture: i386
Kernel:       Linux 2.6.30-2-686

Debian Release: squeeze/sid
  990 testing         localhost 

--- Package information. ---
Depends               (Version) | Installed
===============================-+-=============
python                 (>= 2.4) | 2.5.4-2
python-support      (>= 0.90.0) | 1.0.6
python-gtk2         (>= 2.13.0) | 2.16.0-1
python-gmenu       (>= 2.27.92) | 2.28.0.1-1
gnome-menus        (>= 2.27.92) | 2.28.0.1-1
python-gobject      (>= 2.15.1) | 2.20.0-1


Recommends       (Version) | Installed
==========================-+-===========
gnome-panel                | 2.28.0-3


Package's Suggests field is empty.

-- 

gpg key: https://systemausfall.org/schluessel/lars-devel.0.asc
diff -ruN Alacarte.orig/MainWindow.py Alacarte/MainWindow.py
--- Alacarte.orig/MainWindow.py	2009-12-21 22:59:55.000000000 +0100
+++ Alacarte/MainWindow.py	2009-12-22 14:44:01.000000000 +0100
@@ -260,21 +260,21 @@
 
 	#this is a little timeout callback to insert new items after
 	#gnome-desktop-item-edit has finished running
-	def waitForNewItemProcess(self, process, parent_id, file_path):
+	def waitForNewItemProcess(self, process, parent, file_path):
 		if process.poll() != None:
 			if os.path.isfile(file_path):
-				self.editor.insertExternalItem(os.path.split(file_path)[1], parent_id)
+				self.editor.insertExternalItem(os.path.split(file_path)[1], parent)
 			return False
 		return True
 
-	def waitForNewMenuProcess(self, process, parent_id, file_path):
+	def waitForNewMenuProcess(self, process, parent, file_path):
 		if process.poll() != None:
 			#hack for broken gnome-desktop-item-edit
 			broken_path = os.path.join(os.path.split(file_path)[0], '.directory')
 			if os.path.isfile(broken_path):
 				os.rename(broken_path, file_path)
 			if os.path.isfile(file_path):
-				self.editor.insertExternalMenu(os.path.split(file_path)[1], parent_id)
+				self.editor.insertExternalMenu(os.path.split(file_path)[1], parent)
 			return False
 		return True
 
@@ -296,7 +296,7 @@
 			parent = menus[iter][2]
 		file_path = os.path.join(util.getUserDirectoryPath(), util.getUniqueFileId('alacarte-made', '.directory'))
 		process = subprocess.Popen(['gnome-desktop-item-edit', file_path], env=os.environ)
-		gobject.timeout_add(100, self.waitForNewMenuProcess, process, parent.menu_id, file_path)
+		gobject.timeout_add(100, self.waitForNewMenuProcess, process, parent, file_path)
 
 	def on_new_item_button_clicked(self, button):
 		menu_tree = self.tree.get_object('menu_tree')
@@ -309,7 +309,7 @@
 			parent = menus[iter][2]
 		file_path = os.path.join(util.getUserItemPath(), util.getUniqueFileId('alacarte-made', '.desktop'))
 		process = subprocess.Popen(['gnome-desktop-item-edit', file_path], env=os.environ)
-		gobject.timeout_add(100, self.waitForNewItemProcess, process, parent.menu_id, file_path)
+		gobject.timeout_add(100, self.waitForNewItemProcess, process, parent, file_path)
 
 	def on_new_separator_button_clicked(self, button):
 		item_tree = self.tree.get_object('item_tree')
diff -ruN Alacarte.orig/MenuEditor.py Alacarte/MenuEditor.py
--- Alacarte.orig/MenuEditor.py	2009-12-21 22:59:55.000000000 +0100
+++ Alacarte/MenuEditor.py	2009-12-22 14:43:27.000000000 +0100
@@ -222,10 +222,9 @@
 
 	def createItem(self, parent, icon, name, comment, command, use_term, before=None, after=None):
 		file_id = self.__writeItem(None, icon, name, comment, command, use_term)
-		self.insertExternalItem(file_id, parent.menu_id, before, after)
+		self.insertExternalItem(file_id, parent, before, after)
 
-	def insertExternalItem(self, file_id, parent_id, before=None, after=None):
-		parent = self.__findMenu(parent_id)
+	def insertExternalItem(self, file_id, parent, before=None, after=None):
 		dom = self.__getMenu(parent).dom
 		self.__addItem(parent, file_id, dom)
 		self.__positionItem(parent, ('Item', file_id), before, after)
@@ -234,11 +233,10 @@
 
 	def createMenu(self, parent, icon, name, comment, before=None, after=None):
 		file_id = self.__writeMenu(None, icon, name, comment)
-		self.insertExternalMenu(file_id, parent.menu_id, before, after)
+		self.insertExternalMenu(file_id, parent, before, after)
 
-	def insertExternalMenu(self, file_id, parent_id, before=None, after=None):
+	def insertExternalMenu(self, file_id, parent, before=None, after=None):
 		menu_id = file_id.rsplit('.', 1)[0]
-		parent = self.__findMenu(parent_id)
 		dom = self.__getMenu(parent).dom
 		self.__addXmlDefaultLayout(self.__getXmlMenu(self.__getPath(parent), dom, dom) , dom)
 		menu_xml = self.__getXmlMenu(self.__getPath(parent) + '/' + menu_id, dom, dom)

Attachment: signature.asc
Description: PGP signature

Reply via email to