Changeset 340 for trunk/StreamVision


Ignore:
Timestamp:
09/10/07 22:13:48 (17 years ago)
Author:
Nicholas Riley
Message:

StreamVision.py: Handle Growl disappearance. Syntax updated for
py-appscript 0.18.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StreamVision/StreamVision.py

    r339 r340  
    2323kHIDUsage_Csmr_PlayOrPause = 0xCD
    2424
    25 growl = app('GrowlHelperApp')
    26 
    27 growl.register(
    28     as_application=GROWL_APP_NAME,
    29     all_notifications=NOTIFICATIONS_ALL,
    30     default_notifications=NOTIFICATIONS_ALL,
    31     icon_of_application='iTunes.app')
    32     # if we leave off the .app, we can get Classic iTunes's icon
     25def growlRegister():
     26    global growl
     27    growl = app(id='com.Growl.GrowlHelperApp')
     28
     29    growl.register(
     30        as_application=GROWL_APP_NAME,
     31        all_notifications=NOTIFICATIONS_ALL,
     32        default_notifications=NOTIFICATIONS_ALL,
     33        icon_of_application='iTunes.app')
     34        # if we leave off the .app, we can get Classic iTunes's icon
    3335
    3436def growlNotify(title, description, **kw):
    35     growl.notify(
    36         with_name=NOTIFICATION_TRACK_INFO,
    37         title=title,
    38         description=description,
    39         application_name=GROWL_APP_NAME,
    40         **kw)
     37    try:
     38        growl.notify(
     39            with_name=NOTIFICATION_TRACK_INFO,
     40            title=title,
     41            description=description,
     42            application_name=GROWL_APP_NAME,
     43            **kw)
     44    except CommandError:
     45        growlRegister()
     46        growlNotify(title, description, **kw)
    4147
    4248def radioParadiseURL():
     
    179185    def playPauseFront(self):
    180186        systemEvents = app(id='com.apple.systemEvents')
    181         frontName = systemEvents.processes[its.frontmost][1].name()
     187        frontName = systemEvents.processes[its.frontmost == True][1].name()
    182188        if frontName == 'RealPlayer':
    183189            realPlayer = app(id='com.RealNetworks.RealPlayer')
     
    203209        # XXX detect if "enable access for assistive devices" needs to be enabled
    204210        systemEvents = app(id='com.apple.systemEvents')
    205         frontName = systemEvents.processes[its.frontmost][1].name()
     211        frontName = systemEvents.processes[its.frontmost == True][1].name()
    206212        if frontName == 'iTunes':
    207213            systemEvents.processes['iTunes'].menu_bars[1]. \
     
    213219            self.registerZoomWindowHotKey()
    214220            return
    215         frontPID = systemEvents.processes[its.frontmost][1].unix_id()
     221        frontPID = systemEvents.processes[its.frontmost == True][1].unix_id()
    216222        try:
    217223            zoomed = app(pid=frontPID).windows[1].zoomed
     
    257263
    258264if __name__ == "__main__":
     265    growlRegister()
    259266    AppHelper.runEventLoop()
    260267    try:
Note: See TracChangeset for help on using the changeset viewer.