Exemplo n.º 1
0
	def __loadMenus(self):
		self.applications = Menu()
		self.applications.tree = matemenu.lookup_tree('mate-applications.menu', matemenu.FLAGS_SHOW_EMPTY|matemenu.FLAGS_INCLUDE_EXCLUDED|matemenu.FLAGS_INCLUDE_NODISPLAY|matemenu.FLAGS_SHOW_ALL_SEPARATORS)
		self.applications.visible_tree = matemenu.lookup_tree('mate-applications.menu')
		self.applications.tree.sort_key = matemenu.SORT_DISPLAY_NAME
		self.applications.visible_tree.sort_key = matemenu.SORT_DISPLAY_NAME
		self.applications.path = os.path.join(util.getUserMenuPath(), self.applications.tree.get_menu_file())
		if not os.path.isfile(self.applications.path):
			self.applications.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.applications.tree))
		else:
			self.applications.dom = xml.dom.minidom.parse(self.applications.path)
		self.__remove_whilespace_nodes(self.applications.dom)

		self.settings = Menu()
		self.settings.tree = matemenu.lookup_tree('mate-settings.menu', matemenu.FLAGS_SHOW_EMPTY|matemenu.FLAGS_INCLUDE_EXCLUDED|matemenu.FLAGS_INCLUDE_NODISPLAY|matemenu.FLAGS_SHOW_ALL_SEPARATORS)
		self.settings.visible_tree = matemenu.lookup_tree('mate-settings.menu')
		self.settings.tree.sort_key = matemenu.SORT_DISPLAY_NAME
		self.settings.visible_tree.sort_key = matemenu.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)
Exemplo n.º 2
0
	def __loadMenus(self):
		self.applications = Menu()
		self.applications.tree = matemenu.lookup_tree('mate-applications.menu', matemenu.FLAGS_SHOW_EMPTY|matemenu.FLAGS_INCLUDE_EXCLUDED|matemenu.FLAGS_INCLUDE_NODISPLAY|matemenu.FLAGS_SHOW_ALL_SEPARATORS)
		self.applications.visible_tree = matemenu.lookup_tree('mate-applications.menu')
		self.applications.tree.sort_key = matemenu.SORT_DISPLAY_NAME
		self.applications.visible_tree.sort_key = matemenu.SORT_DISPLAY_NAME
		self.applications.path = os.path.join(util.getUserMenuPath(), self.applications.tree.get_menu_file())
		try:
			self.applications.dom = xml.dom.minidom.parse(self.applications.path)
		except (IOError, xml.parsers.expat.ExpatError):
			self.applications.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.applications.tree))
		util.removeWhitespaceNodes(self.applications.dom)

		self.settings = Menu()
		self.settings.tree = matemenu.lookup_tree('mate-settings.menu', matemenu.FLAGS_SHOW_EMPTY|matemenu.FLAGS_INCLUDE_EXCLUDED|matemenu.FLAGS_INCLUDE_NODISPLAY|matemenu.FLAGS_SHOW_ALL_SEPARATORS)
		self.settings.visible_tree = matemenu.lookup_tree('mate-settings.menu')
		self.settings.tree.sort_key = matemenu.SORT_DISPLAY_NAME
		self.settings.visible_tree.sort_key = matemenu.SORT_DISPLAY_NAME
		self.settings.path = os.path.join(util.getUserMenuPath(), self.settings.tree.get_menu_file())
		try:
			self.settings.dom = xml.dom.minidom.parse(self.settings.path)
		except (IOError, xml.parsers.expat.ExpatError):
			self.settings.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.settings.tree))
		util.removeWhitespaceNodes(self.settings.dom)

		self.save(True)
Exemplo n.º 3
0
 def quit(self):
     for file_name in os.listdir(util.getUserItemPath()):
         if file_name[-6:-2] in ('redo', 'undo'):
             file_path = os.path.join(util.getUserItemPath(), file_name)
             os.unlink(file_path)
     for file_name in os.listdir(util.getUserDirectoryPath()):
         if file_name[-6:-2] in ('redo', 'undo'):
             file_path = os.path.join(util.getUserDirectoryPath(), file_name)
             os.unlink(file_path)
     for file_name in os.listdir(util.getUserMenuPath()):
         if file_name[-6:-2] in ('redo', 'undo'):
             file_path = os.path.join(util.getUserMenuPath(), file_name)
             os.unlink(file_path)
Exemplo n.º 4
0
 def quit(self):
     for file_name in os.listdir(util.getUserItemPath()):
         if file_name[-6:-2] in ('redo', 'undo'):
             file_path = os.path.join(util.getUserItemPath(), file_name)
             os.unlink(file_path)
     for file_name in os.listdir(util.getUserDirectoryPath()):
         if file_name[-6:-2] in ('redo', 'undo'):
             file_path = os.path.join(util.getUserDirectoryPath(), file_name)
             os.unlink(file_path)
     for file_name in os.listdir(util.getUserMenuPath()):
         if file_name[-6:-2] in ('redo', 'undo'):
             file_path = os.path.join(util.getUserMenuPath(), file_name)
             os.unlink(file_path)
Exemplo n.º 5
0
    def __loadMenus(self):
        self.applications.path = os.path.join(util.getUserMenuPath(), self.applications.tree.props.menu_basename)
        try:
            self.applications.dom = xml.dom.minidom.parse(self.applications.path)
        except (IOError, xml.parsers.expat.ExpatError):
            self.applications.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.applications.tree))
        util.removeWhitespaceNodes(self.applications.dom)

        self.settings.path = os.path.join(util.getUserMenuPath(), self.settings.tree.props.menu_basename)
        try:
            self.settings.dom = xml.dom.minidom.parse(self.settings.path)
        except (IOError, xml.parsers.expat.ExpatError):
            self.settings.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.settings.tree))
        util.removeWhitespaceNodes(self.settings.dom)
        self.save(True)
Exemplo n.º 6
0
    def __loadMenus(self):
        self.applications.path = os.path.join(util.getUserMenuPath(), self.applications.tree.props.menu_basename)
        try:
            self.applications.dom = xml.dom.minidom.parse(self.applications.path)
        except (IOError, xml.parsers.expat.ExpatError):
            self.applications.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.applications.tree))
        util.removeWhitespaceNodes(self.applications.dom)

        self.settings.path = os.path.join(util.getUserMenuPath(), self.settings.tree.props.menu_basename)
        try:
            self.settings.dom = xml.dom.minidom.parse(self.settings.path)
        except (IOError, xml.parsers.expat.ExpatError):
            self.settings.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.settings.tree))
        util.removeWhitespaceNodes(self.settings.dom)
        self.save(True)
    def __loadMenus(self):
        self.applications = Menu()
        self.applications.tree = matemenu.lookup_tree(
            'mate-applications.menu',
            matemenu.FLAGS_SHOW_EMPTY | matemenu.FLAGS_INCLUDE_EXCLUDED
            | matemenu.FLAGS_INCLUDE_NODISPLAY
            | matemenu.FLAGS_SHOW_ALL_SEPARATORS)
        self.applications.visible_tree = matemenu.lookup_tree(
            'mate-applications.menu')
        self.applications.tree.sort_key = matemenu.SORT_DISPLAY_NAME
        self.applications.visible_tree.sort_key = matemenu.SORT_DISPLAY_NAME
        self.applications.path = os.path.join(
            util.getUserMenuPath(), self.applications.tree.get_menu_file())
        if not os.path.isfile(self.applications.path):
            self.applications.dom = xml.dom.minidom.parseString(
                util.getUserMenuXml(self.applications.tree))
        else:
            self.applications.dom = xml.dom.minidom.parse(
                self.applications.path)
        self.__remove_whilespace_nodes(self.applications.dom)

        self.settings = Menu()
        self.settings.tree = matemenu.lookup_tree(
            'mate-settings.menu',
            matemenu.FLAGS_SHOW_EMPTY | matemenu.FLAGS_INCLUDE_EXCLUDED
            | matemenu.FLAGS_INCLUDE_NODISPLAY
            | matemenu.FLAGS_SHOW_ALL_SEPARATORS)
        self.settings.visible_tree = matemenu.lookup_tree('mate-settings.menu')
        self.settings.tree.sort_key = matemenu.SORT_DISPLAY_NAME
        self.settings.visible_tree.sort_key = matemenu.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)
Exemplo n.º 8
0
 def revert(self):
     for name in ('applications', 'settings'):
         menu = getattr(self, name)
         self.revertTree(menu.tree.get_root_directory())
         path = os.path.join(util.getUserMenuPath(), menu.tree.props.menu_basename)
         try:
             os.unlink(path)
         except OSError:
             pass
         #reload DOM for each menu
         try:
             menu.dom = xml.dom.minidom.parse(menu.path)
         except (IOError, xml.parsers.expat.ExpatError):
             menu.dom = xml.dom.minidom.parseString(util.getUserMenuXml(menu.tree))
         util.removeWhitespaceNodes(menu.dom)
     #reset undo/redo, no way to recover from this
     self.__undo, self.__redo = [], []
     self.save()
Exemplo n.º 9
0
	def revert(self):
		for name in ('applications', 'settings'):
			menu = getattr(self, name)
			self.revertTree(menu.tree.root)
			path = os.path.join(util.getUserMenuPath(), menu.tree.get_menu_file())
			try:
				os.unlink(path)
			except OSError:
				pass
			#reload DOM for each menu
			if not os.path.isfile(menu.path):
				menu.dom = xml.dom.minidom.parseString(util.getUserMenuXml(menu.tree))
			else:
				menu.dom = xml.dom.minidom.parse(menu.path)
			self.__remove_whilespace_nodes(menu.dom)
		#reset undo/redo, no way to recover from this
		self.__undo, self.__redo = [], []
		self.save()
Exemplo n.º 10
0
 def revert(self):
     for name in ('applications', 'settings'):
         menu = getattr(self, name)
         self.revertTree(menu.tree.get_root_directory())
         path = os.path.join(util.getUserMenuPath(), menu.tree.props.menu_basename)
         try:
             os.unlink(path)
         except OSError:
             pass
         #reload DOM for each menu
         try:
             menu.dom = xml.dom.minidom.parse(menu.path)
         except (IOError, xml.parsers.expat.ExpatError):
             menu.dom = xml.dom.minidom.parseString(util.getUserMenuXml(menu.tree))
         util.removeWhitespaceNodes(menu.dom)
     #reset undo/redo, no way to recover from this
     self.__undo, self.__redo = [], []
     self.update_undo_redo_button_state()
     self.save()
 def revert(self):
     for name in ('applications', 'settings'):
         menu = getattr(self, name)
         self.revertTree(menu.tree.root)
         path = os.path.join(util.getUserMenuPath(),
                             menu.tree.get_menu_file())
         try:
             os.unlink(path)
         except OSError:
             pass
         #reload DOM for each menu
         if not os.path.isfile(menu.path):
             menu.dom = xml.dom.minidom.parseString(
                 util.getUserMenuXml(menu.tree))
         else:
             menu.dom = xml.dom.minidom.parse(menu.path)
         self.__remove_whilespace_nodes(menu.dom)
     #reset undo/redo, no way to recover from this
     self.__undo, self.__redo = [], []
     self.save()