OSDN Git Service

move main.py into gui/ so it gets installed
[mypaint-anime/master.git] / gui / main.py
1 # This file is part of MyPaint.
2 # Copyright (C) 2007-2009 by Martin Renold <martinxyz@gmx.ch>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
9 import sys
10 import gtk
11 from gui import application
12
13 # main entry, called from the "mypaint" script
14 def main(datapath, confpath):
15
16     def usage_exit():
17         print sys.argv[0], '[OPTION]... [FILENAME]'
18         print 'Options:'
19         print '  -c /path/to/config   use this directory instead of ~/.mypaint/'
20         print '  -p                   profile (debug only; simulate some strokes and quit)'
21         sys.exit(1)
22
23     filename = None
24     profile = False
25
26     args = sys.argv[1:]
27     while args:
28         arg = args.pop(0)
29         if arg == '-c':
30             confpath = args.pop(0)
31         elif arg == '-p':
32             profile = True
33         elif arg.startswith('-'):
34             usage_exit()
35         else:
36             if filename:
37                 print 'Cannot open more than one file!'
38                 sys.exit(2)
39             filename = arg
40             if not os.path.isfile(filename):
41                 print 'File', filename, 'does not exist!'
42                 sys.exit(2)
43
44     print 'confpath =', confpath
45     app = application.Application(datapath, confpath, filename, profile)
46
47     # Recent gtk versions don't allow changing those menu shortcuts by
48     # default. <rant>Sigh. This very useful feature used to be the
49     # default behaviour even in the GIMP some time ago. I guess
50     # assigning a keyboard shortcut without a complicated dialog
51     # clicking marathon must have totally upset the people coming from
52     # windows.</rant>
53     gtksettings = gtk.settings_get_default()
54     gtksettings.set_property('gtk-can-change-accels', True)
55
56     gtk.main()