From 1b4a150dcacc8038989fbf60b648c3595a22583a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 6 Jul 2011 15:55:35 -0400 Subject: [PATCH] add initial empty Window class --- Window.py | 17 +++++++++++++++++ pygtk-imap-chk.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 Window.py create mode 100755 pygtk-imap-chk.py diff --git a/Window.py b/Window.py new file mode 100755 index 0000000..0159496 --- /dev/null +++ b/Window.py @@ -0,0 +1,17 @@ + +import gtk + +class Window(object): + def __init__(self): + self.window = gtk.Window() + self.window.set_decorated(False) + self.window.connect('destroy', self.destroy_event) + + self.window.show_all() + + def run(self): + gtk.main() + + def destroy_event(self): + gtk.main_quit() + return False diff --git a/pygtk-imap-chk.py b/pygtk-imap-chk.py new file mode 100755 index 0000000..1790c43 --- /dev/null +++ b/pygtk-imap-chk.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +import sys +import gtk +import imaplib + +from Window import * + +def get_config(fname): + conf = {} + if os.path.isfile(fname): + try: + f = open(fname, 'r') + contents = f.read() + f.close() + exec(contents, conf) + except: + pass + return conf + +def save_config(fname, conf): + if os.path.isfile(fname): + fh = open(fname, 'r') + old_config = fh.read() + fh.close() + else: + old_config = '' + new_config = '' + conf_ents = filter(lambda x: not x.startswith('_'), conf) + for s in map(lambda x: x + ' = ' + repr(conf[x]) + '\n', conf_ents): + new_config += s + if old_config != new_config: + fh = open(fname, 'w') + fh.write(new_config) + fh.close() + +def main(argv): + window = Window() + window.run() + +if __name__ == "__main__": + sys.exit(main(sys.argv))