[SCM] morituri/master: * examples/ARcue.py: Add option to run either command-line or gtk.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:08:45 UTC 2014


The following commit has been merged in the master branch:
commit 729280ef427fe3f1af013d4f6e002b501e553021
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sun Apr 12 11:15:45 2009 +0000

    	* examples/ARcue.py:
    	  Add option to run either command-line or gtk.

diff --git a/ChangeLog b/ChangeLog
index 6a898c6..a9037db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-04-12  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+	* examples/ARcue.py:
+	  Add option to run either command-line or gtk.
+
+2009-04-12  Thomas Vander Stichele  <thomas at apestaart dot org>
+
 	* morituri/image/image.py:
 	  Create a MultiTask base class, and make AudioRipCRCTask
 	  use it.
diff --git a/examples/ARcue.py b/examples/ARcue.py
index df6915c..c87dcdc 100644
--- a/examples/ARcue.py
+++ b/examples/ARcue.py
@@ -21,29 +21,60 @@
 # along with morituri.  If not, see <http://www.gnu.org/licenses/>.
 
 import sys
+import optparse
 
 import gobject
 gobject.threads_init()
+import gtk
 
 from morituri.image import image
 from morituri.common import task, crc
 
-def main(path):
+def gtkmain(taskk):
+    progress = task.GtkProgressRunner()
+    progress.connect('stop', lambda _: gtk.main_quit())
+
+    window = gtk.Window()
+    window.add(progress)
+    window.show_all()
+
+    progress.run(taskk)
+
+    gtk.main()
+
+def climain(taskk):
     runner = task.SyncRunner()
 
-    cueImage = image.Image(path)
+    runner.run(taskk)
 
-    cuetask = image.AudioRipCRCTask(cueImage)
-    runner.run(cuetask)
 
-    for i, crc in enumerate(cuetask.crcs):
-        print "Track %2d: %08x" % (i, crc)
+def main(argv):
+    parser = optparse.OptionParser()
+
+    default = 'cli'
+    parser.add_option('-r', '--runner',
+        action="store", dest="runner",
+        help="runner ('cli' or 'gtk', defaults to %s)" % default,
+        default=default)
 
-path = 'test.cue'
+    options, args = parser.parse_args(argv[1:])
 
-try:
-    path = sys.argv[1]
-except IndexError:
-    pass
+    path = 'test.cue'
+
+    try:
+        path = sys.argv[1]
+    except IndexError:
+        pass
+
+    cueImage = image.Image(path)
+    cuetask = image.AudioRipCRCTask(cueImage)
+
+    if options.runner == 'cli':
+        climain(cuetask)
+    elif options.runner == 'gtk':
+        gtkmain(cuetask)
+
+    for i, crc in enumerate(cuetask.crcs):
+        print "Track %2d: %08x" % (i + 1, crc)
 
-main(path)
+main(sys.argv)

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list