Commits

Anonymous committed aaa01d0

Extend k3b.py (reiter.christoph) and rename, closing issue #32.

  • Participants
  • Parent commits 4f01d6a

Comments (0)

Files changed (2)

plugins/songsmenu/burncd.py

+# Copyright 2005 Joe Wreschnig
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation
+#
+# $Id$
+
+import os
+import gtk
+
+from quodlibet import util
+from quodlibet import config
+from quodlibet.qltk import ErrorMessage
+from plugins.songsmenu import SongsMenuPlugin
+
+class BurnCD(SongsMenuPlugin):
+    PLUGIN_ID = 'Burn CD'
+    PLUGIN_NAME = _('Burn CD')
+    PLUGIN_DESC = 'Burn CDs with K3b or Brasero'
+    PLUGIN_ICON = 'gtk-cdrom'
+    PLUGIN_VERSION = '0.15'
+
+    burn_programs = {
+        'K3b': ['k3b', '--audiocd'],
+        'Brasero': ['brasero', '--audio']
+    }
+
+    try:
+        config.get("plugins", __name__)
+    except:
+        config.set("plugins", __name__, burn_programs.keys()[0])
+
+    def PluginPreferences(klass, window):
+        vb = gtk.HBox(spacing=10)
+        vb.set_border_width(10)
+        label = gtk.Label(_("_Program:"))
+        combo = gtk.combo_box_new_text()
+
+        select = 0
+        name = config.get("plugins", __name__)
+        for i, prog in enumerate(klass.burn_programs.iterkeys()):
+            combo.append_text(prog)
+            if prog == name:
+                select = i
+
+        combo.set_active(select)
+        combo.connect('changed',
+            lambda e: config.set('plugins', __name__, e.get_active_text()))
+
+        label.set_mnemonic_widget(combo)
+        label.set_use_underline(True)
+        vb.pack_start(label, expand=False)
+        vb.pack_start(combo, expand=False)
+        vb.show_all()
+        return vb
+
+    PluginPreferences = classmethod(PluginPreferences)
+
+    def plugin_songs(self, songs):
+        name = config.get("plugins", __name__)
+        prog = self.burn_programs[name]
+
+        if not util.iscommand(prog[0]):
+            ErrorMessage(
+                None, "%s not found" % name,
+                "The %s burning program was not found. " % name).run()
+        else:
+            files = [song['~filename'] for song in songs]
+            util.spawn(prog + files)

plugins/songsmenu/k3b.py

-# Copyright 2005 Joe Wreschnig
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation
-#
-# $Id$
-
-import os
-import util
-from qltk import ErrorMessage
-from plugins.songsmenu import SongsMenuPlugin
-
-class K3b(SongsMenuPlugin):
-    PLUGIN_ID = 'Burn CD'
-    PLUGIN_NAME = _('Burn CD')
-    PLUGIN_DESC = 'Burn CDs with K3b.'
-    PLUGIN_ICON = 'gtk-cdrom'
-    PLUGIN_VERSION = '0.15'
-
-    def plugin_songs(self, songs):
-        if not util.iscommand("k3b"):
-            ErrorMessage(
-                None, "K3b not found",
-                "The K3b burning program was not found. "
-                "You can get K3b at http://k3b.sourceforge.net.").run()
-        else:
-            files = [song['~filename'] for song in songs]
-            try: util.spawn
-            except:
-                if len(files) == 1: filelist = "%r" % files[0]
-                else: filelist = ("%r " * len(files)) % tuple(files)
-                os.system('k3b --audiocd %s &' % filelist)
-            else:
-                util.spawn(["k3b", "--audiocd"] + files)