~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to test-appindicator.py

  • Committer: Jason Conti
  • Date: 2010-08-29 00:51:28 UTC
  • Revision ID: jason.conti@gmail.com-20100829005128-o1i8hjzpp02id9ko
The size-allocate signal was not properly updating with the panel size. Found the change-size signal, and now the icon gets properly resized when the panel size changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
test-appindicator.py
 
3
August 16, 2010
 
4
"""
 
5
 
 
6
import appindicator
 
7
import gtk
 
8
 
 
9
from recent_notifications.Notification import Notification
 
10
 
 
11
main_menu = None
 
12
indicator = None
 
13
message_items = []
 
14
 
 
15
def on_message_received(monitor, message):
 
16
  global main_menu
 
17
  global indicator
 
18
  if len(message_items) >= 5:
 
19
    last_item = message_items.pop()
 
20
    main_menu.remove(last_item)
 
21
    last_item.destroy()
 
22
  main_menu.prepend(gtk.SeparatorMenuItem())
 
23
  current_item = gtk.MenuItem(message.summary)
 
24
  main_menu.prepend(current_item)
 
25
  message_items.insert(0, current_item)
 
26
  main_menu.show_all()
 
27
  indicator.set_menu(main_menu)
 
28
  indicator.set_status(appindicator.STATUS_ATTENTION)
 
29
 
 
30
def main():
 
31
  global main_menu
 
32
  global indicator
 
33
  main_menu = gtk.Menu()
 
34
  default_item = gtk.MenuItem("Show Message Window")
 
35
  main_menu.add(default_item)
 
36
  main_menu.show_all()
 
37
  main_menu.set_take_focus(False)
 
38
  indicator = appindicator.Indicator("test", "humanity-notification-read", appindicator.CATEGORY_OTHER)
 
39
  indicator.set_attention_icon("humanity-notification-unread")
 
40
  indicator.set_status(appindicator.STATUS_ACTIVE)
 
41
  indicator.set_menu(main_menu)
 
42
  notify = Notification()
 
43
  notify.connect("message-received", on_message_received)
 
44
  gtk.main()
 
45
 
 
46
if __name__ == '__main__':
 
47
  main()