home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-xdg / examples / test-menu.py < prev   
Encoding:
Python Source  |  2005-06-02  |  758 b   |  25 lines

  1. #!/usr/bin/python
  2.  
  3. import sys
  4.  
  5. import xdg.Menu
  6. import xdg.DesktopEntry
  7.  
  8. def show_menu(menu, depth = 0):
  9. #    print depth*"-" + "\x1b[01m" + menu.getName().encode("ascii", 'ignore') + "\x1b[0m"
  10. #    depth += 1
  11.     for entry in menu.getEntries():
  12.         if isinstance(entry, xdg.Menu.Menu):
  13.             show_menu(entry, depth)
  14.         elif isinstance(entry, xdg.Menu.MenuEntry):
  15. #            print depth*"-" + entry.DesktopEntry.getName().encode("ascii", 'ignore')
  16.             print menu.getPath() + "/\t" + entry.DesktopFileID + "\t" + entry.DesktopEntry.getFileName()
  17. #        elif isinstance(entry, xdg.Menu.Separator):
  18. #            print depth*"-" + "|||"
  19. #        elif isinstance(entry, xdg.Menu.Header):
  20. #            print depth*"-" + "\x1b[01m" + entry.Name + "\x1b[0m"
  21. #    depth -= 1
  22.  
  23. show_menu(xdg.Menu.parse())
  24. #xdg.Menu.parse()
  25.