#! /usr/bin/env python

import gettext
gettext.install('postr')

import sys
from twisted.internet import gtk2reactor
reactor = gtk2reactor.install()

# If postr is not installed we can run it from source
try:
    from postr import postr
except ImportError, e:
    print e
    from os.path import dirname
    sys.path.insert(0, dirname(__file__))
    from src import postr

p = postr.Postr()
if p.is_running():
    for url in sys.argv[1:]:
        p.open_uri(url)
    sys.exit(0)
else:
    p.window.show()
    p.add_window(p.window)
    for url in sys.argv[1:]:
        p.add_image_filename(url)
    reactor.run()
