~mblayman/entertainer/clean-up-1.0

« back to all changes in this revision

Viewing changes to src/entertainer-tray-icon.py

  • Committer: Paul Hummer
  • Date: 2008-06-21 06:10:59 UTC
  • mto: This revision was merged to the branch mainline in revision 256.
  • Revision ID: paul@ubuntu.com-20080621061059-a55dg8p5hlr0k1jr
Moves many files and directories

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
'''System tray icon for Entertainer backend'''
3
 
 
4
 
import sys
5
 
import os
6
 
import gobject
7
 
import ConfigParser
8
 
from ConfigParser import ParsingError
9
 
 
10
 
try:
11
 
    import pygtk
12
 
    pygtk.require("2.4")
13
 
except:
14
 
    pass
15
 
try:
16
 
    import gtk
17
 
except:
18
 
    sys.exit(1)
19
 
 
20
 
from backend.core.message import Message
21
 
from backend.core.message_type_priority import MessageType, MessagePriority
22
 
from backend.core.message_bus_proxy import MessageBusProxy
23
 
from utils.system_tray_icon import SystemTrayIcon
24
 
 
25
 
message_dict = { MessageType.RECORDING_STARTED : MessagePriority.VERY_LOW,
26
 
                 MessageType.RECORDING_STOPPED : MessagePriority.VERY_LOW}
27
 
 
28
 
gobject.threads_init()
29
 
gtk.gdk.threads_init()
30
 
 
31
 
# Create tray icon
32
 
gtk.gdk.threads_enter()
33
 
 
34
 
#Start SystemTrayIcon with show on start True
35
 
tray_icon = SystemTrayIcon(start_frontend=True)
36
 
gtk.gdk.threads_leave()
37
 
 
38
 
try:
39
 
    # Open connection to backend
40
 
    proxy = MessageBusProxy(message_dict, tray_icon.get_message_handler(),
41
 
        "system-tray-icon")
42
 
    proxy.connectToMessageBus()
43
 
    proxy.start()
44
 
    tray_icon.get_message_handler().set_message_bus_proxy(proxy)
45
 
 
46
 
except:
47
 
    print "Backend is not running. Start backend and try again."
48
 
    sys.exit(1)
49
 
 
50
 
gtk.gdk.threads_enter()
51
 
gtk.main()
52
 
gtk.gdk.threads_leave()