Posted By


ssoton on 11/22/12

Tagged


Statistics


Viewed 755 times
Favorited by 0 user(s)

Appindicator facade


/ Published in: Python
Save to your folder(s)

snippet to show appindicator problem


Copy this code and paste it in your HTML
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import gobject
  5. import pygtk
  6. pygtk.require('2.0')
  7. import gtk
  8. import appindicator
  9. import sys
  10.  
  11.  
  12. class AppIndicatorExample:
  13. def __init__(self):
  14. self.ind = appindicator.Indicator ("example-simple-client",
  15. "indicator-messages",
  16. appindicator.CATEGORY_APPLICATION_STATUS)
  17. self.ind.set_attention_icon ("indicator-messages-new")
  18. self.ind.set_icon("distributor-logo")
  19. self.inicialice()
  20.  
  21. def inicialice(self):
  22. # create a menu
  23. self.menu = gtk.Menu()
  24.  
  25. # create items for the menu - labels, checkboxes, radio buttons and images
  26. # are supported:
  27. item = gtk.MenuItem("Regular Menu Item")
  28. item.show()
  29. self.menu.append(item)
  30.  
  31. check = gtk.CheckMenuItem("Check Menu Item")
  32. check.show()
  33. self.menu.append(check)
  34.  
  35. radio = gtk.RadioMenuItem(None, "Radio Menu Item")
  36. radio.show()
  37. self.menu.append(radio)
  38.  
  39. image = gtk.ImageMenuItem(gtk.STOCK_QUIT)
  40. image.connect("activate", self.quit)
  41. image.show()
  42. self.menu.append(image)
  43.  
  44. self.menu.show()
  45.  
  46. self.ind.set_menu(self.menu)
  47.  
  48. def show(self):
  49. self.ind.set_status (appindicator.STATUS_ACTIVE)
  50.  
  51. def quit(self, widget=None, data=None):
  52. self.ind.set_status(appindicator.STATUS_PASSIVE)
  53. self.menu.destroy()
  54. gtk.main_quit()
  55.  
  56.  
  57. def quit_in_5(indicator):
  58. indicator.quit()
  59. print "Executing quit"
  60. return 0
  61.  
  62.  
  63. if __name__ == "__main__":
  64. indicator = AppIndicatorExample()
  65. indicator.show()
  66.  
  67. # this timeout help us to reproduce the problem. It gives you 5 seconds
  68. # to display the indator menu making clic on the icon
  69. gobject.timeout_add(5000, quit_in_5, indicator)
  70. gtk.main()

URL: appindicator_facade

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.