Changeset 211
- Timestamp:
- 01/29/06 22:59:56 (19 years ago)
- Location:
- trunk/StreamVision
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/StreamVision/HotKeymodule.c
r193 r211 13 13 14 14 static PyObject 15 * StreamVision_HotKeyAddress(PyObject *self, PyObject *args) {15 *HotKey_HotKeyAddress(PyObject *self, PyObject *args) { 16 16 PyObject *v; 17 17 if (!PyArg_ParseTuple(args, "O", &v)) … … 24 24 } 25 25 26 static PyMethodDef _StreamVisionmodule_methods[] = {27 {"HotKeyAddress", StreamVision_HotKeyAddress, METH_VARARGS,26 static PyMethodDef HotKeymodule_methods[] = { 27 {"HotKeyAddress", HotKey_HotKeyAddress, METH_VARARGS, 28 28 "HotKeyAddress(_CarbonEvt.EventHotKeyRef) -> integer\n\n" 29 29 "Return the address of the underlying EventHotKeyRef (passed as data1 in hot key NSEvents)."}, … … 32 32 33 33 PyMODINIT_FUNC 34 init _StreamVision(void) {35 (void)Py_InitModule(" _StreamVision", _StreamVisionmodule_methods);34 initHotKey(void) { 35 (void)Py_InitModule("HotKey", HotKeymodule_methods); 36 36 } -
trunk/StreamVision/StreamVision.py
r200 r211 7 7 from PyObjCTools import AppHelper 8 8 from Carbon.CarbonEvt import RegisterEventHotKey, GetApplicationEventTarget 9 from Carbon.Events import cmdKey 9 from Carbon.Events import cmdKey, shiftKey 10 10 import struct 11 11 import scrape 12 import _StreamVision12 import HotKey 13 13 14 14 GROWL_APP_NAME = 'StreamVision' … … 75 75 def displayTrackInfo(self): 76 76 iTunes = iTunesApp() 77 if iTunes.player_state.get() == k.playing: 78 if iTunes.current_track.class_.get() == k.URL_track: 79 growlNotify(cleanStreamTitle(iTunes.current_stream_title.get()), 80 cleanStreamTrackName(iTunes.current_track.name.get())) 81 else: 82 kw = {} 83 artwork = iTunes.current_track.artworks.get() 84 if artwork: 85 kw['pictImage'] = artwork[0].data.get() 86 growlNotify(iTunes.current_track.name.get() + ' ' + 87 '★' * (iTunes.current_track.rating.get() / 20), 88 iTunes.current_track.album.get() + "\n" + 89 iTunes.current_track.artist.get(), 90 **kw) 91 else: 92 trackName = '' 93 if iTunes.current_track.class_.get() != k.Property: 94 trackName = iTunes.current_track.name.get() 95 growlNotify("iTunes is not playing.", trackName) 77 78 trackClass = iTunes.current_track.class_.get() 79 trackName = '' 80 if trackClass != k.Property: 81 trackName = iTunes.current_track.name.get() 82 83 if iTunes.player_state.get() != k.playing: 84 growlNotify('iTunes is not playing.', trackName) 85 return 86 if trackClass == k.URL_track: 87 growlNotify(cleanStreamTitle(iTunes.current_stream_title.get()), 88 cleanStreamTrackName(trackName)) 89 return 90 if trackClass == k.Property: 91 growlNotify('iTunes is playing.', '') 92 return 93 kw = {} 94 # XXX iTunes doesn't let you get artwork for shared tracks 95 if trackClass != k.shared_track: 96 artwork = iTunes.current_track.artworks.get() 97 if artwork: 98 kw['pictImage'] = artwork[0].data.get() 99 growlNotify(trackName + ' ' + 100 '★' * (iTunes.current_track.rating.get() / 20), 101 iTunes.current_track.album.get() + "\n" + 102 iTunes.current_track.artist.get(), 103 **kw) 96 104 97 105 def goToSite(self): … … 110 118 GetApplicationEventTarget(), 0) 111 119 self.hotKeys.append(hotKeyRef) 112 self.hotKeyActions[ _StreamVision.HotKeyAddress(hotKeyRef)] = func120 self.hotKeyActions[HotKey.HotKeyAddress(hotKeyRef)] = func 113 121 114 122 def incrementRatingBy(self, increment): … … 140 148 self.registerHotKey(lambda: iTunesApp().previous_track(), 109) # F10 141 149 self.registerHotKey(lambda: iTunesApp().next_track(), 103) # F11 142 self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, cmdKey) # cmd-F10143 self.registerHotKey(lambda: self.incrementRatingBy(20), 103, cmdKey) # cmd-F11150 self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, shiftKey) # shift-F10 151 self.registerHotKey(lambda: self.incrementRatingBy(20), 103, shiftKey) # shift-F11 144 152 NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.displayTrackInfo, 'com.apple.iTunes.playerInfo', None) 145 153 -
trunk/StreamVision/setup.py
r188 r211 17 17 setup( 18 18 app=["StreamVision.py"], 19 ext_modules=[Extension(' _StreamVision',20 sources=[' _StreamVisionmodule.c'],19 ext_modules=[Extension('HotKey', 20 sources=['HotKeymodule.c'], 21 21 extra_link_args=['-framework', 'Carbon'])], 22 22 data_files=["English.lproj"],
Note:
See TracChangeset
for help on using the changeset viewer.