Compare commits

...

8 Commits
v1.2 ... master

Author SHA1 Message Date
fc7c80d6ec update README 2011-12-21 12:34:50 -05:00
Josh Holtrop
fae48b4a8d rework handling of 'sticky' conf item to match others 2011-07-19 14:32:42 -04:00
Josh Holtrop
cf66a347b1 ignore distribution directories 2011-07-19 14:31:41 -04:00
Josh Holtrop
183a5c8076 add 'always_on_top' config item and capability 2011-07-19 14:31:12 -04:00
Josh Holtrop
07756a8b19 work around Windows issue with Popen()/py2exe 2011-07-19 11:28:06 -04:00
Josh Holtrop
290395903e v1.3 2011-07-19 11:20:33 -04:00
Josh Holtrop
0e27e17597 add documentation for 'mouse' configuration item 2011-07-19 11:20:11 -04:00
Josh Holtrop
5c714a69c4 make mouse click actions configurable 2011-07-19 11:08:48 -04:00
3 changed files with 52 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
build build
dist dist
pygtk-imap-chk-v?.?

20
README
View File

@ -1,4 +1,4 @@
PyGTK IMAP Checker v1.2 PyGTK IMAP Checker v1.3
By Josh Holtrop By Josh Holtrop
This script creates an undecorated window containing a number which tracks This script creates an undecorated window containing a number which tracks
@ -38,6 +38,24 @@ Available configuration parameters:
This value will be updated by the program when it closes. This value will be updated by the program when it closes.
'mailbox': String giving the name of the mailbox directory to search for 'mailbox': String giving the name of the mailbox directory to search for
the unread message count (if unspecified, uses "Inbox"). the unread message count (if unspecified, uses "Inbox").
You may specify subfolders such as "Inbox/Folder".
'mouse': A hash which configures the actions for the program to take
in response to a mouse click. The keys of this hash can be
'left', 'middle', or 'right'. The values of the hash can take
the following forms:
'exit' - the program will terminate
'reconnect' - the program will reconnect to the IMAP server
'cmd:COMMAND' - the command COMMAND will be executed
The cmd:COMMAND form can be used to execute arbitrary processes
in response to a mouse click. This can be used to raise a mail
client window, for example:
mouse = {
'middle': 'reconnect',
'right': 'exit',
'left': 'cmd:"C:\\Program Files\\Microsoft Office\\'
'Office12\\OUTLOOK.EXE" /recycle '
'/select "outlook:Sent Items"'
}
'password': String containing the password to use to connect to the server 'password': String containing the password to use to connect to the server
'port': String containing the port number of the IMAP SSL port on 'port': String containing the port number of the IMAP SSL port on
the mail server. the mail server.

View File

@ -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,18 +31,30 @@ 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'
if not 'always_on_top' in self.conf:
self.conf['always_on_top'] = True
if not 'sticky' in self.conf:
self.conf['sticky'] = True
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']))
sticky = True
if 'sticky' in self.conf:
sticky = self.conf['sticky']
self.window = gtk.Window() self.window = gtk.Window()
self.window.set_title(title) self.window.set_title(title)
self.window.set_decorated(False) self.window.set_decorated(False)
if sticky: if self.conf['sticky']:
self.window.stick() self.window.stick()
if self.conf['always_on_top']:
self.window.set_keep_above(True)
self.window.connect('destroy', self.destroy_event) self.window.connect('destroy', self.destroy_event)
self.label = gtk.Label('-') self.label = gtk.Label('-')
@ -138,9 +152,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:
self.disconnect() btn_name = {1: 'left', 2: 'middle', 3: 'right'}[event.button]
self.connect() action = self.conf['mouse'][btn_name]
elif event.button == 3: m = re.match(r'\s*cmd:\s*(.*)', action)
self.destroy_event() if m is not None:
cmd = m.group(1)
Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
elif action == 'reconnect':
self.disconnect()
self.connect()
elif action == 'exit':
self.destroy_event()
except KeyError:
return False
return True return True