Example #1
0
	def __addUndo(self, items):
		self.__undo.append([])
		for item in items:
			if isinstance(item, Menu):
				file_path = item.path
			elif isinstance(item, tuple):
				if item[0] == 'Item':
					file_path = os.path.join(util.getUserItemPath(), item[1])
					if not os.path.isfile(file_path):
						file_path = util.getItemPath(item[1])
				elif item[0] == 'Menu':
					file_path = os.path.join(util.getUserDirectoryPath(), item[1])
					if not os.path.isfile(file_path):
						file_path = util.getDirectoryPath(item[1])
				else:
					continue
			elif item.get_type() == gmenu.TYPE_DIRECTORY:
				if item.get_desktop_file_path() == None:
					continue
				file_path = os.path.join(util.getUserDirectoryPath(), os.path.split(item.get_desktop_file_path())[1])
				if not os.path.isfile(file_path):
					file_path = item.get_desktop_file_path()
			elif item.get_type() == gmenu.TYPE_ENTRY:
				file_path = os.path.join(util.getUserItemPath(), item.get_desktop_file_id())
				if not os.path.isfile(file_path):
					file_path = item.get_desktop_file_path()
			else:
				continue
			data = open(file_path).read()
			undo_path = util.getUniqueUndoFile(file_path)
			open(undo_path, 'w').write(data)
			self.__undo[-1].append(undo_path)
Example #2
0
	def __addUndo(self, items):
		self.__undo.append([])
		for item in items:
			if isinstance(item, Menu):
				file_path = item.path
			elif isinstance(item, tuple):
				if item[0] == 'Item':
					file_path = os.path.join(util.getUserItemPath(), item[1])
					if not os.path.isfile(file_path):
						file_path = util.getItemPath(item[1])
				elif item[0] == 'Menu':
					file_path = os.path.join(util.getUserDirectoryPath(), item[1])
					if not os.path.isfile(file_path):
						file_path = util.getDirectoryPath(item[1])
				else:
					continue
			elif item.get_type() == gmenu.TYPE_DIRECTORY:
				if item.get_desktop_file_path() == None:
					continue
				file_path = os.path.join(util.getUserDirectoryPath(), os.path.split(item.get_desktop_file_path())[1])
				if not os.path.isfile(file_path):
					file_path = item.get_desktop_file_path()
			elif item.get_type() == gmenu.TYPE_ENTRY:
				file_path = os.path.join(util.getUserItemPath(), item.get_desktop_file_id())
				if not os.path.isfile(file_path):
					file_path = item.get_desktop_file_path()
			else:
				continue
			data = open(file_path).read()
			undo_path = util.getUniqueUndoFile(file_path)
			open(undo_path, 'w').write(data)
			self.__undo[-1].append(undo_path)
Example #3
0
 def canRevert(self, item):
     if isinstance(item, GMenu.TreeEntry):
         if util.getItemPath(item.get_desktop_file_id()) is not None:
             path = util.getUserItemPath()
             if os.path.isfile(os.path.join(path, item.get_desktop_file_id())):
                 return True
     elif isinstance(item, GMenu.TreeDirectory):
         if item.get_desktop_file_path():
             file_id = os.path.split(item.get_desktop_file_path())[1]
         else:
             file_id = item.get_menu_id() + '.directory'
         if util.getDirectoryPath(file_id) is not None:
             path = util.getUserDirectoryPath()
             if os.path.isfile(os.path.join(path, file_id)):
                 return True
     return False
Example #4
0
	def canRevert(self, item):
		if item.get_type() == gmenu.TYPE_ENTRY:
			if util.getItemPath(item.get_desktop_file_id()):
				path = util.getUserItemPath()
				if os.path.isfile(os.path.join(path, item.get_desktop_file_id())):
					return True
		elif item.get_type() == gmenu.TYPE_DIRECTORY:
			if item.get_desktop_file_path():
				file_id = os.path.split(item.get_desktop_file_path())[1]
			else:
				file_id = item.get_menu_id() + '.directory'
			if util.getDirectoryPath(file_id):
				path = util.getUserDirectoryPath()
				if os.path.isfile(os.path.join(path, file_id)):
					return True
		return False
Example #5
0
	def canRevert(self, item):
		if item.get_type() == gmenu.TYPE_ENTRY:
			if util.getItemPath(item.get_desktop_file_id()):
				path = util.getUserItemPath()
				if os.path.isfile(os.path.join(path, item.get_desktop_file_id())):
					return True
		elif item.get_type() == gmenu.TYPE_DIRECTORY:
			if item.get_desktop_file_path():
				file_id = os.path.split(item.get_desktop_file_path())[1]
			else:
				file_id = item.get_menu_id() + '.directory'
			if util.getDirectoryPath(file_id):
				path = util.getUserDirectoryPath()
				if os.path.isfile(os.path.join(path, file_id)):
					return True
		return False
Example #6
0
 def canRevert(self, item):
     if isinstance(item, GMenu.TreeEntry):
         if util.getItemPath(item.get_desktop_file_id()) is not None:
             path = util.getUserItemPath()
             if os.path.isfile(
                     os.path.join(path, item.get_desktop_file_id())):
                 return True
     elif isinstance(item, GMenu.TreeDirectory):
         if item.get_desktop_file_path():
             file_id = os.path.split(item.get_desktop_file_path())[1]
         else:
             file_id = item.get_menu_id() + '.directory'
         if util.getDirectoryPath(file_id) is not None:
             path = util.getUserDirectoryPath()
             if os.path.isfile(os.path.join(path, file_id)):
                 return True
     return False