#!/usr/bin/env python

# add-copyrights-to-images
#
# Copyright (C) 2011 Tim Marston <edam@waxworlds.org>
#
# This file is part of add-copyright-to-images (hereafter referred to as "this
# program").
# See http://www.waxworlds.org/edam/software/add-copyright-to-images for more
# information.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


# version @PACKAGE_VERSION@


import sys
from os.path import join, abspath, exists

# check for a development source directory and use that if it's there
PACKAGE_DIR = join( abspath( sys.path[ 0 ] ), ".." )
if exists( join( PACKAGE_DIR, "add_copyright_to_images", "prefs_dialog.py" ) ):
    print "!!! using development packages !!!"
    sys.path.insert( 0, PACKAGE_DIR )
else:
    del PACKAGE_DIR

import pygtk
pygtk.require( '2.0' );
import gtk
from add_copyright_to_images.main_window import *

# no arguments?
if( len( sys.argv[ 1: ] ) == 0 ):
    dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, \
        gtk.BUTTONS_CLOSE, "No images specified" )
    dialog.format_secondary_text( "You must select some files first!" )
    dialog.run()
    dialog.destroy()
    exit( 1 )

# process each image in turn
for filename in sys.argv[ 1: ]:
    MainWindow( filename ).main()
