def __loadMenus(self): self.applications = Menu() self.applications.tree = gmenu.lookup_tree('applications.menu', gmenu.FLAGS_SHOW_EMPTY|gmenu.FLAGS_INCLUDE_EXCLUDED|gmenu.FLAGS_INCLUDE_NODISPLAY|gmenu.FLAGS_SHOW_ALL_SEPARATORS) self.applications.visible_tree = gmenu.lookup_tree('applications.menu') self.applications.tree.sort_key = gmenu.SORT_DISPLAY_NAME self.applications.visible_tree.sort_key = gmenu.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 = 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 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)
def __init__(self, name='cinnamon-applications.menu'): self.name = name self.tree = GMenu.Tree.new(name, GMenu.TreeFlags.SHOW_EMPTY|GMenu.TreeFlags.INCLUDE_EXCLUDED|GMenu.TreeFlags.INCLUDE_NODISPLAY|GMenu.TreeFlags.SHOW_ALL_SEPARATORS|GMenu.TreeFlags.SORT_DISPLAY_NAME) self.tree.connect('changed', self.menuChanged) self.load() self.path = os.path.join(util.getUserMenuPath(), self.tree.props.menu_basename) self.loadDOM()
def __init__(self, basename=None): basename = basename or get_default_menu() self.tree = GMenu.Tree.new(basename, GMenu.TreeFlags.SHOW_EMPTY|GMenu.TreeFlags.INCLUDE_EXCLUDED|GMenu.TreeFlags.INCLUDE_NODISPLAY|GMenu.TreeFlags.SHOW_ALL_SEPARATORS|GMenu.TreeFlags.SORT_DISPLAY_NAME) self.tree.connect('changed', self.menuChanged) self.load() self.path = os.path.join(util.getUserMenuPath(), self.tree.props.menu_basename) self.loadDOM()
def restoreToSystem(self): self.restoreTree(self.tree.get_root_directory()) path = os.path.join(util.getUserMenuPath(), os.path.basename(self.tree.get_canonical_menu_path())) try: os.unlink(path) except OSError: pass self.loadDOM() self.save()
def __init__(self, name='applications.menu'): menu_prefix = os.getenv('XDG_MENU_PREFIX') or 'gnome-' name = menu_prefix + name self.name = name self.tree = GMenu.Tree.new(name, GMenu.TreeFlags.SHOW_EMPTY|GMenu.TreeFlags.INCLUDE_EXCLUDED|GMenu.TreeFlags.INCLUDE_NODISPLAY|GMenu.TreeFlags.SHOW_ALL_SEPARATORS|GMenu.TreeFlags.SORT_DISPLAY_NAME) self.tree.connect('changed', self.menuChanged) self.load() self.path = os.path.join(util.getUserMenuPath(), self.tree.props.menu_basename) self.loadDOM()
def restoreToSystem(self): self.restoreTree(self.tree.get_root_directory()) path = os.path.join( util.getUserMenuPath(), os.path.basename(self.tree.get_canonical_menu_path())) try: os.unlink(path) except OSError: pass self.loadDOM() self.save()
def __init__(self, name='cinnamon-applications.menu'): self.name = name self.tree = GMenu.Tree.new( name, GMenu.TreeFlags.SHOW_EMPTY | GMenu.TreeFlags.INCLUDE_EXCLUDED | GMenu.TreeFlags.INCLUDE_NODISPLAY | GMenu.TreeFlags.SHOW_ALL_SEPARATORS | GMenu.TreeFlags.SORT_DISPLAY_NAME) self.tree.connect('changed', self.menuChanged) self.load() self.path = os.path.join(util.getUserMenuPath(), self.tree.props.menu_basename) self.loadDOM()
def __loadMenus(self): self.applications = Menu() self.applications.tree = gmenu.lookup_tree('cinnamon-applications.menu', gmenu.FLAGS_SHOW_EMPTY|gmenu.FLAGS_INCLUDE_EXCLUDED|gmenu.FLAGS_INCLUDE_NODISPLAY|gmenu.FLAGS_SHOW_ALL_SEPARATORS) self.applications.visible_tree = gmenu.lookup_tree('cinnamon-applications.menu') self.applications.tree.sort_key = gmenu.SORT_DISPLAY_NAME self.applications.visible_tree.sort_key = gmenu.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.save(True)
def __init__(self, basename=None): basename = basename or get_default_menu() self.tree = GMenu.Tree.new( basename, GMenu.TreeFlags.SHOW_EMPTY | GMenu.TreeFlags.INCLUDE_EXCLUDED | GMenu.TreeFlags.INCLUDE_NODISPLAY | GMenu.TreeFlags.SHOW_ALL_SEPARATORS | GMenu.TreeFlags.SORT_DISPLAY_NAME) self.tree.connect('changed', self.menuChanged) self.load() self.path = os.path.join(util.getUserMenuPath(), self.tree.props.menu_basename) self.loadDOM()
def __init__(self, name='applications.menu'): menu_prefix = os.getenv('XDG_MENU_PREFIX') or 'gnome-' name = menu_prefix + name self.name = name self.tree = GMenu.Tree.new( name, GMenu.TreeFlags.SHOW_EMPTY | GMenu.TreeFlags.INCLUDE_EXCLUDED | GMenu.TreeFlags.INCLUDE_NODISPLAY | GMenu.TreeFlags.SHOW_ALL_SEPARATORS | GMenu.TreeFlags.SORT_DISPLAY_NAME) self.tree.connect('changed', self.menuChanged) self.load() self.path = os.path.join(util.getUserMenuPath(), self.tree.props.menu_basename) self.loadDOM()
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()
def revert(self): for name in ('applications',): 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()