make mouse click actions configurable
This commit is contained in:
parent
e8918895f4
commit
5c714a69c4
23
Window.py
23
Window.py
@ -1,9 +1,11 @@
|
|||||||
|
|
||||||
|
import re
|
||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
import imaplib
|
import imaplib
|
||||||
import math
|
import math
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from subprocess import *
|
||||||
|
|
||||||
class Window(object):
|
class Window(object):
|
||||||
def __init__(self, title, conf):
|
def __init__(self, title, conf):
|
||||||
@ -29,6 +31,14 @@ class Window(object):
|
|||||||
self.conf['flash_rate'] = 3000
|
self.conf['flash_rate'] = 3000
|
||||||
if not 'font_size' in self.conf:
|
if not 'font_size' in self.conf:
|
||||||
self.conf['font_size'] = 18
|
self.conf['font_size'] = 18
|
||||||
|
if not 'mouse' in self.conf:
|
||||||
|
self.conf['mouse'] = {}
|
||||||
|
if not 'left' in self.conf['mouse']:
|
||||||
|
self.conf['mouse']['left'] = ''
|
||||||
|
if not 'middle' in self.conf['mouse']:
|
||||||
|
self.conf['mouse']['middle'] = 'reconnect'
|
||||||
|
if not 'right' in self.conf['mouse']:
|
||||||
|
self.conf['mouse']['right'] = 'exit'
|
||||||
self.font_sz = int(1024 * self.conf['font_size'])
|
self.font_sz = int(1024 * self.conf['font_size'])
|
||||||
self.fgcolor = ''.join(map(lambda x: '%02x' % int(0xFF * x),
|
self.fgcolor = ''.join(map(lambda x: '%02x' % int(0xFF * x),
|
||||||
self.conf['fgcolor']))
|
self.conf['fgcolor']))
|
||||||
@ -138,9 +148,18 @@ class Window(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def button_release(self, widget, event):
|
def button_release(self, widget, event):
|
||||||
if event.button == 2:
|
try:
|
||||||
|
btn_name = {1: 'left', 2: 'middle', 3: 'right'}[event.button]
|
||||||
|
action = self.conf['mouse'][btn_name]
|
||||||
|
m = re.match(r'\s*cmd:\s*(.*)', action)
|
||||||
|
if m is not None:
|
||||||
|
cmd = m.group(1)
|
||||||
|
Popen(cmd, stdout=PIPE)
|
||||||
|
elif action == 'reconnect':
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self.connect()
|
self.connect()
|
||||||
elif event.button == 3:
|
elif action == 'exit':
|
||||||
self.destroy_event()
|
self.destroy_event()
|
||||||
|
except KeyError:
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user