diff options
-rw-r--r-- | clMonty.py | 11 | ||||
-rw-r--r-- | montypc.py | 13 | ||||
-rw-r--r-- | plugins/Shortcuts.py | 148 |
3 files changed, 14 insertions, 158 deletions
@@ -56,12 +56,13 @@ class Monty(QtCore.QObject): """Connect to MPD@$host:$port. Returns true at success, false otherwise.""" if self._client: return + #self._client = jmpc.jmpc() self._client = mpd.MPDClient() - try: - self._client.connect(host, port) - except: - self._client=None - return False + #try: + self._client.connect(host, port) + #except: + #self._client=None + #return False self._raiseEvent('onConnect', None) try: @@ -8,16 +8,19 @@ from winMain import winMain from winSettings import winSettings from clMonty import monty from traceback import print_exc - -#import profile - - +#import hotshot, hotshot.stats try: wMain = winMain() wMain.show() app.exec_() + #prof=hotshot.Profile("profile") + #prof.runcall(app.exec_) + #prof.close() + #stats=hotshot.stats.load("profile") + #stats.strip_dirs() + #stats.sort_stats('time','calls') + #stats.print_stats(20) except Exception, e: print_exc() -#profile.run('app.exec_()') diff --git a/plugins/Shortcuts.py b/plugins/Shortcuts.py deleted file mode 100644 index 7a73ac7..0000000 --- a/plugins/Shortcuts.py +++ /dev/null @@ -1,148 +0,0 @@ -from PyQt4 import QtGui, QtCore - -from Xlib.display import Display -from Xlib import X -from thread import start_new_thread - -from clPlugin import Plugin -from clSettings import settings - - -#~ http://www.exaile.org/files/plugins/0.2.13/xkey.py - -class pluginShortcuts(Plugin): - def __init__(self, winMain): - # [key] [button] [ 1=pressed 0=unpressed ] [ a function the key will call ] - # [ ] [text ] [ leave this 0 ] [ or a direct exaile command ] - # v v v v v v v v v v - # keyb = 'name':[keyname,keycode,shift,ctrl,alt,mod1,mod2,callback,callback-arguments] - # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ - # keyb = '* ':[str ,int ,int ,int ,int,int,int ,str ,str ] - - - self.keyb = { - 'play': ['a', 1, 1, 1, 1, 0, 0, 'gogo','1'], - 'stop': ['not defined', 0, 0, 0, 0, 0, 0, 'APP.player.stop',''], - 'pause': ['not defined', 0, 0, 0, 0, 0, 0, 'APP.player.toggle_pause',''], - 'next Track': ['not defined', 0, 0, 0, 0, 0, 0, 'APP.player.next',''], - 'previous Track':['not defined', 0, 0, 0, 0, 0, 0, 'APP.player.previous',''], - 'seek forward': ['not defined', 0, 0, 0, 0, 0, 0, 'seekForward','5'], - 'seek backward': ['not defined', 0, 0, 0, 0, 0, 0, 'seekBack','5'], - 'volume up': ['not defined', 0, 0, 0, 0, 0, 0, 'volUp5','2'], - 'volume down': ['not defined', 0, 0, 0, 0, 0, 0, 'volDown5','2'], - 'show osd': ['not defined', 0, 0, 0, 0, 0, 0, 'APP.show_osd',''], - } - - # connect loaded settings with X - # start listening - self.listen() - - def getName(self): - return "Shortcuts" - - def ButtonHit(self,event): - def gogo(step): - print "meheheh" - - - def getInfo(self): - return "Control playing using shortcuts." - - def _getSettings(self): - return [ - #['shortcuts.playpauze', 'Play/pauze', 'Key to start playing/pauze.', QtGui.QLineEdit(settings.get('shortcuts.playpauze', 'Win+Home'))], - ] - def afterSaveSettings(self): - pass - -################################################################################## -# -# If you want to add your custom shortcut, this is as far as you have to edit this -# file. The Rest is generic stuff that should work with any action. As long as it -# follows following pattern: -# -# in the __init__ method: -# a valid entry(see comments) in the keyb dictionary and actionlist -# -# optional: -# in the Buttonhit method: -# a function called by the 7the entry in the dict -# -# in the extras method: -# additional config menu items -# -################################################################################## - - - def freeKey(self): - '''####################################################################### - stop grabbing without a trace (i hope) - ''' - - source_remove(self.listener) - self.grabKey('free') - - - def grabKey(self,action): - '''####################################################################### - Connect / disconnect Keys to grab - ''' - # Make a xlib Mask for every key in the settings-dict - for key in self.keyb.keys(): - if self.keyb[key][0] != 'not defined': - maske = '' - if self.keyb[key][2] == 1: - maske += '|X.ShiftMask' - if self.keyb[key][3] == 1: - maske += '|X.ControlMask' - if self.keyb[key][4] == 1: - maske += '|X.Mod1Mask' - if self.keyb[key][5] == 1: - maske += '|X.Mod2Mask' - if self.keyb[key][6] == 1: - maske += '|X.Mod3Mask' - - - def checkmask(maske): - # make sure the mask is valid - if maske != '': - amaske = maske.lstrip('|') - return eval(amaske) - else: - return X.AnyModifier - - if action == 'grab': - # ...and grab it... - print 'grab hit' - self.root.grab_key(self.keyb[key][1], checkmask(maske), 1,X.GrabModeAsync, X.GrabModeAsync) - print 'grabbed '+str(self.keyb[key][1]) - elif action == 'free': - # ...or ungrab it. - self.root.ungrab_key(self.keyb[key][1], checkmask(maske)) - self.disp.flush() - print 'ungrabbed '+str(self.keyb[key][1]) - - def listen(self): - '''########################################################################## - connect xlib to the dictionary with the keys - ''' - - - # select display to listen on - self.disp = Display() - self.root = self.disp.screen().root - # specify event - self.root.change_attributes(event_mask = X.KeyPressMask) - - self.grabKey('grab') - - print 'listening' - def checkKey(arg1,arg2): - print arg1,arg2 - event = self.disp.next_event() - if event.type == X.KeyPress: - self.ButtonHit(event.detail) - return True - - #~ self.listener = io_add_watch(self.disp, 1 ,checkKey) - print self.disp.pending_events() |