OSDN Git Service

moved commandline parsing into main.py and renamed mypaint.in
authorMartin Renold <martinxyz@gmx.ch>
Fri, 20 Mar 2009 18:09:46 +0000 (18:09 +0000)
committerMartin Renold <martinxyz@gmx.ch>
Fri, 20 Mar 2009 18:09:46 +0000 (18:09 +0000)
svn://svn.gna.org/svn/mypaint/trunk@298

SConstruct
gui/application.py
main.py [new file with mode: 0644]
mypaint.in.py [moved from mypaint.in with 97% similarity]

index d3522f3..511a81b 100644 (file)
@@ -75,7 +75,7 @@ def burn_python_version(target, source, env):
     f.write(s)
     f.close()
 
-env.Command('mypaint', 'mypaint.in', [burn_python_version, Chmod('$TARGET', 0755)])
+env.Command('mypaint', 'mypaint.in.py', [burn_python_version, Chmod('$TARGET', 0755)])
 
 env.Alias('install', env['prefix'])
 def install(dst, pattern):
index e711e70..a8116f5 100644 (file)
@@ -176,47 +176,3 @@ class Application: # singleton
         if name in 'drawWindow brushSelectionWindow colorSelectionWindow'.split():
             window.show_all()
 
-# main entry, called from the "mypaint" script
-def main(datapath, confpath):
-
-    def usage_exit():
-        print sys.argv[0], '[OPTION]... [FILENAME]'
-        print 'Options:'
-        print '  -c /path/to/config   use this directory instead of ~/.mypaint/'
-        print '  -p                   profile (debug only; simulate some strokes and quit)'
-        sys.exit(1)
-
-    filename = None
-    profile = False
-
-    args = sys.argv[1:]
-    while args:
-        arg = args.pop(0)
-        if arg == '-c':
-            confpath = args.pop(0)
-        elif arg == '-p':
-            profile = True
-        elif arg.startswith('-'):
-            usage_exit()
-        else:
-            if filename:
-                print 'Cannot open more than one file!'
-                sys.exit(2)
-            filename = arg
-            if not os.path.isfile(filename):
-                print 'File', filename, 'does not exist!'
-                sys.exit(2)
-
-    print 'confpath =', confpath
-    app = Application(datapath, confpath, filename, profile)
-
-    # Recent gtk versions don't allow changing those menu shortcuts by
-    # default. <rant>Sigh. This very useful feature used to be the
-    # default behaviour even in the GIMP some time ago. I guess
-    # assigning a keyboard shortcut without a complicated dialog
-    # clicking marathon must have totally upset the people coming from
-    # windows.</rant>
-    gtksettings = gtk.settings_get_default()
-    gtksettings.set_property('gtk-can-change-accels', True)
-
-    gtk.main()
diff --git a/main.py b/main.py
new file mode 100644 (file)
index 0000000..702e881
--- /dev/null
+++ b/main.py
@@ -0,0 +1,56 @@
+# This file is part of MyPaint.
+# Copyright (C) 2007-2009 by Martin Renold <martinxyz@gmx.ch>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import gtk
+from gui import application
+
+# main entry, called from the "mypaint" script
+def main(datapath, confpath):
+
+    def usage_exit():
+        print sys.argv[0], '[OPTION]... [FILENAME]'
+        print 'Options:'
+        print '  -c /path/to/config   use this directory instead of ~/.mypaint/'
+        print '  -p                   profile (debug only; simulate some strokes and quit)'
+        sys.exit(1)
+
+    filename = None
+    profile = False
+
+    args = sys.argv[1:]
+    while args:
+        arg = args.pop(0)
+        if arg == '-c':
+            confpath = args.pop(0)
+        elif arg == '-p':
+            profile = True
+        elif arg.startswith('-'):
+            usage_exit()
+        else:
+            if filename:
+                print 'Cannot open more than one file!'
+                sys.exit(2)
+            filename = arg
+            if not os.path.isfile(filename):
+                print 'File', filename, 'does not exist!'
+                sys.exit(2)
+
+    print 'confpath =', confpath
+    app = application.Application(datapath, confpath, filename, profile)
+
+    # Recent gtk versions don't allow changing those menu shortcuts by
+    # default. <rant>Sigh. This very useful feature used to be the
+    # default behaviour even in the GIMP some time ago. I guess
+    # assigning a keyboard shortcut without a complicated dialog
+    # clicking marathon must have totally upset the people coming from
+    # windows.</rant>
+    gtksettings = gtk.settings_get_default()
+    gtksettings.set_property('gtk-can-change-accels', True)
+
+    gtk.main()
similarity index 97%
rename from mypaint.in
rename to mypaint.in.py
index 164038f..e0f96a9 100644 (file)
@@ -71,5 +71,5 @@ if homepath == '~':
 else:
     confpath = join(homepath, '.mypaint/')
 
-from gui import application
-application.main(datapath, confpath)
+import main
+main.main(datapath, confpath)