pygtk-imap-chk/Window.py
Josh Holtrop a701c69dc0 set window position based on configuration
save window configuration on exit
2011-07-06 16:29:09 -04:00

45 lines
1.2 KiB
Python
Executable File

import gtk
import imaplib
class Window(object):
def __init__(self, conf):
self.conf = conf
if not 'width' in self.conf:
self.conf['width'] = 32
if not 'height' in self.conf:
self.conf['height'] = 32
self.window = gtk.Window()
self.window.set_default_size(self.conf['width'], self.conf['height'])
self.window.set_decorated(False)
self.window.connect('destroy', self.destroy_event)
self.window.connect('button-release-event', self.button_release)
self.window.set_events(gtk.gdk.BUTTON_RELEASE_MASK)
if 'x' in self.conf and 'y' in self.conf:
self.window.move(self.conf['x'], self.conf['y'])
self.window.show_all()
def run(self):
gtk.main()
def update_conf(self):
w, h = self.window.get_size()
self.conf['width'] = w
self.conf['height'] = h
x, y = self.window.get_position()
self.conf['x'] = x
self.conf['y'] = y
def destroy_event(self):
self.update_conf()
gtk.main_quit()
return False
def button_release(self, widget, event):
if event.button == 3:
self.destroy_event()
return True