]> git.0d.be Git - jack_mixer.git/commitdiff
Do not allow duplicated channel names
authorFrédéric Péters <fpeters@0d.be>
Sat, 12 Dec 2009 22:24:26 +0000 (23:24 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sat, 12 Dec 2009 22:24:26 +0000 (23:24 +0100)
channel.py
jack_mixer.py

index c5291e9254144e65c8ba0f4d92529a0e5b02f76b..76a19ffb522b65548ff4760944fee002a238fcac 100644 (file)
@@ -394,7 +394,7 @@ class input_channel(channel):
     channel_properties_dialog = None
     def on_channel_properties(self):
         if not self.channel_properties_dialog:
-            self.channel_properties_dialog = ChannelPropertiesDialog(self)
+            self.channel_properties_dialog = ChannelPropertiesDialog(self, self.app)
         self.channel_properties_dialog.show()
         self.channel_properties_dialog.present()
 
@@ -540,7 +540,7 @@ class output_channel(channel):
     channel_properties_dialog = None
     def on_channel_properties(self):
         if not self.channel_properties_dialog:
-            self.channel_properties_dialog = OutputChannelPropertiesDialog(self)
+            self.channel_properties_dialog = OutputChannelPropertiesDialog(self, self.app)
         self.channel_properties_dialog.show()
         self.channel_properties_dialog.present()
 
@@ -695,8 +695,11 @@ def main_mix_serialization_name():
 
 
 class ChannelPropertiesDialog(gtk.Dialog):
-    def __init__(self, parent):
+    channel = None
+
+    def __init__(self, parent, app):
         self.channel = parent
+        self.app = app
         self.mixer = self.channel.mixer
         gtk.Dialog.__init__(self,
                         'Channel "%s" Properties' % self.channel.channel_name,
@@ -828,12 +831,21 @@ class ChannelPropertiesDialog(gtk.Dialog):
             self.channel.channel.balance_midi_cc = int(self.entry_balance_cc.get_text())
 
     def on_entry_name_changed(self, entry):
-        self.ok_button.set_sensitive(len(entry.get_text()))
+        sensitive = False
+        if len(entry.get_text()):
+            if self.channel and self.channel.channel.name == entry.get_text():
+                sensitive = True
+            elif entry.get_text() not in [x.channel.name for x in self.app.channels] + \
+                        [x.channel.name for x in self.app.output_channels] + ['MAIN']:
+                sensitive = True
+        self.ok_button.set_sensitive(sensitive)
+
 
 class NewChannelDialog(ChannelPropertiesDialog):
-    def __init__(self, parent, mixer):
-        gtk.Dialog.__init__(self, 'New Channel', parent)
-        self.mixer = mixer
+    def __init__(self, app):
+        gtk.Dialog.__init__(self, 'New Channel', app.window)
+        self.mixer = app.mixer
+        self.app = app
         self.create_ui()
 
         self.stereo.set_active(True) # default to stereo
@@ -873,9 +885,10 @@ class OutputChannelPropertiesDialog(ChannelPropertiesDialog):
 
 
 class NewOutputChannelDialog(OutputChannelPropertiesDialog):
-    def __init__(self, parent, mixer):
-        gtk.Dialog.__init__(self, 'New Output Channel', parent)
-        self.mixer = mixer
+    def __init__(self, app):
+        gtk.Dialog.__init__(self, 'New Output Channel', app.window)
+        self.mixer = app.mixer
+        self.app = app
         self.create_ui()
 
         # TODO: disable mode for output channels as mono output channels may
index 58f6c6af69df709ff57cddb5bfff752f3a483a90..214fb9fb3549169dd07d353ec2c7de9aa6d37827 100755 (executable)
@@ -241,7 +241,7 @@ class jack_mixer(serialized_object):
         self.preferences_dialog.present()
 
     def on_add_input_channel(self, widget):
-        dialog = NewChannelDialog(parent=self.window, mixer=self.mixer)
+        dialog = NewChannelDialog(app=self)
         dialog.set_transient_for(self.window)
         dialog.show()
         ret = dialog.run()
@@ -253,7 +253,7 @@ class jack_mixer(serialized_object):
             self.window.show_all()
 
     def on_add_output_channel(self, widget):
-        dialog = NewOutputChannelDialog(parent=self.window, mixer=self.mixer)
+        dialog = NewOutputChannelDialog(app=self)
         dialog.set_transient_for(self.window)
         dialog.show()
         ret = dialog.run()