/gtk/prep-images

To get this branch, use:
bzr branch http://bzr.ed.am/gtk/prep-images

« back to all changes in this revision

Viewing changes to src/prep-images.in

  • Committer: edam
  • Date: 2011-04-08 14:47:29 UTC
  • Revision ID: edam@waxworlds.org-20110408144729-2fn36ra6akxjgesi
- renamed project from add-copyright-to-images to prep-images
- rejigged layout of files in project
- made some formatting consistent

Show diffs side-by-side

added added

removed removed

22
22
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
 
25
 
# @PACKAGE_NAME@ version @PACKAGE_VERSION@
26
 
 
27
 
import sys, os
 
25
# version @PACKAGE_VERSION@
 
26
 
 
27
 
 
28
import sys
28
29
from os.path import join, abspath, exists
29
 
import getopt
30
 
 
31
30
 
32
31
# check for a development source directory and use that if it's there
33
32
PACKAGE_DIR = join( abspath( sys.path[ 0 ] ), "..", "lib" )
34
33
if exists( join( PACKAGE_DIR, "prep_images", "prefs_dialog.py" ) ):
35
 
        print >> sys.stderr, "!!! using development packages !!!"
 
34
        print "!!! using development packages !!!"
36
35
        sys.path.insert( 0, PACKAGE_DIR )
37
36
else:
38
37
        del PACKAGE_DIR
39
38
 
40
 
 
41
 
def usage( error = True ):
42
 
        print >> sys.stderr, 'Try "@PACKAGE_NAME@ --help" for help'
43
 
        exit( 1 )
44
 
 
45
 
 
46
 
def help():
47
 
        print "Usage: @PACKAGE_NAME@ [OPTION]... FILE..."
48
 
        print
49
 
        print "Prepare the specified image FILEs for publishing."
50
 
        print
51
 
        print "Options:"
52
 
        print "     --help     display this help and exit"
53
 
        print "     --version  output version information and exit"
54
 
        exit( 0 )
55
 
 
56
 
 
57
 
def version():
58
 
        print "@PACKAGE_NAME@ @PACKAGE_VERSION@"
59
 
        print
60
 
        print "Copyright (C) 2011 to 2013 Tim Marston"
61
 
        print "License GPLv3+: GNU GPL version 3 or later " + \
62
 
            "<http://gnu.org/licenses/gpl.html>"
63
 
        print "This is free software: you are free to change and " + \
64
 
            "redistribute it."
65
 
        print
66
 
        print "For more information, including documentation, see the " +\
67
 
            "project website, at"
68
 
        print "<@PACKAGE_URL@>. Please report bugs to <@PACKAGE_BUGREPORT@>."
69
 
        exit( 0 )
70
 
 
71
 
 
72
 
# handle command line
73
 
try:
74
 
        opts, args = getopt.gnu_getopt(
75
 
                sys.argv[ 1: ], "",
76
 
                [ "help", "version" ] )
77
 
except getopt.GetoptError as e:
78
 
        print str( e )
79
 
        usage()
80
 
 
81
 
# process options
82
 
for opt, args in opts:
83
 
        if opt == "--help":
84
 
                help()
85
 
        elif opt == "--version":
86
 
                version()
87
 
        else:
88
 
                print >> sys.stderr, "unknown option"
89
 
                usage()
90
 
 
91
 
# check for files
92
 
if len( args ) == 0:
93
 
        print >> sys.stderr, "no files specified"
94
 
        usage()
95
 
 
96
 
# try to detect no DISPLAY
97
 
if os.getenv( 'DISPLAY', '' ) == '':
98
 
        print >> sys.stderr, 'could not open display'
99
 
        exit( 1 )
100
 
 
101
 
# we only now import the main window stuff, because it pulls in PyGTK which
102
 
# complains if it can't connect to a display
 
39
import pygtk
 
40
pygtk.require( '2.0' );
 
41
import gtk
103
42
from prep_images.main_window import *
104
43
 
 
44
# no arguments?
 
45
if( len( sys.argv[ 1: ] ) == 0 ):
 
46
        dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, \
 
47
                gtk.BUTTONS_CLOSE, "No images specified" )
 
48
        dialog.format_secondary_text( "You must select some files first!" )
 
49
        dialog.run()
 
50
        dialog.destroy()
 
51
        exit( 1 )
 
52
 
105
53
# process each image in turn
106
 
for filename in args:
 
54
for filename in sys.argv[ 1: ]:
107
55
        MainWindow( filename ).main()