]> git.0d.be Git - jack_mixer.git/commitdiff
Serialize mute/solo status
authorFrédéric Péters <fpeters@0d.be>
Sat, 12 Dec 2009 22:12:14 +0000 (23:12 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sat, 12 Dec 2009 22:12:14 +0000 (23:12 +0100)
channel.py
jack_mixer.py

index fb19345ade024ce46008ab653e20b470131a161d..c5291e9254144e65c8ba0f4d92529a0e5b02f76b 100644 (file)
@@ -371,6 +371,7 @@ class input_channel(channel):
         control_group = ControlGroup(channel, self)
         control_group.show_all()
         self.vbox.pack_start(control_group, False)
         control_group = ControlGroup(channel, self)
         control_group.show_all()
         self.vbox.pack_start(control_group, False)
+        return control_group
 
     def update_control_group(self, channel):
         for control_group in self.vbox.get_children():
 
     def update_control_group(self, channel):
         for control_group in self.vbox.get_children():
@@ -378,6 +379,13 @@ class input_channel(channel):
                 if control_group.output_channel is channel:
                     control_group.update()
 
                 if control_group.output_channel is channel:
                     control_group.update()
 
+    def get_control_group(self, channel):
+        for control_group in self.vbox.get_children():
+            if isinstance(control_group, ControlGroup):
+                if control_group.output_channel is channel:
+                    return control_group
+        return None
+
     def unrealize(self):
         channel.unrealize(self)
         self.channel.remove()
     def unrealize(self):
         channel.unrealize(self)
         self.channel.remove()
@@ -445,6 +453,9 @@ class output_channel(channel):
     colours = available_colours[:]
     _display_solo_buttons = False
 
     colours = available_colours[:]
     _display_solo_buttons = False
 
+    _init_muted_channels = None
+    _init_solo_channels = None
+
     def __init__(self, app, name, stereo):
         channel.__init__(self, app, name, stereo)
 
     def __init__(self, app, name, stereo):
         channel.__init__(self, app, name, stereo)
 
@@ -515,6 +526,17 @@ class output_channel(channel):
         self.monitor_button.connect('toggled', self.on_monitor_button_toggled)
         self.pack_start(self.monitor_button, False, False)
 
         self.monitor_button.connect('toggled', self.on_monitor_button_toggled)
         self.pack_start(self.monitor_button, False, False)
 
+        # add control groups to the input channels, and initialize them
+        # appropriately
+        for input_channel in self.app.channels:
+            ctlgroup = input_channel.add_control_group(self)
+            if self._init_muted_channels and input_channel.channel.name in self._init_muted_channels:
+                ctlgroup.mute.set_active(True)
+            if self._init_solo_channels and input_channel.channel.name in self._init_solo_channels:
+                ctlgroup.solo.set_active(True)
+        self._init_muted_channels = None
+        self._init_solo_channels = None
+
     channel_properties_dialog = None
     def on_channel_properties(self):
         if not self.channel_properties_dialog:
     channel_properties_dialog = None
     def on_channel_properties(self):
         if not self.channel_properties_dialog:
@@ -542,6 +564,17 @@ class output_channel(channel):
             object_backend.add_property("type", "mono")
         if self.display_solo_buttons:
             object_backend.add_property("solo_buttons", "true")
             object_backend.add_property("type", "mono")
         if self.display_solo_buttons:
             object_backend.add_property("solo_buttons", "true")
+        muted_channels = []
+        solo_channels = []
+        for input_channel in self.app.channels:
+            if self.channel.is_muted(input_channel.channel):
+                muted_channels.append(input_channel)
+            if self.channel.is_solo(input_channel.channel):
+                solo_channels.append(input_channel)
+        if muted_channels:
+            object_backend.add_property('muted_channels', '|'.join([x.channel.name for x in muted_channels]))
+        if solo_channels:
+            object_backend.add_property('solo_channels', '|'.join([x.channel.name for x in solo_channels]))
         channel.serialize(self, object_backend)
 
     def unserialize_property(self, name, value):
         channel.serialize(self, object_backend)
 
     def unserialize_property(self, name, value):
@@ -558,12 +591,22 @@ class output_channel(channel):
         if name == "solo_buttons":
             if value == "true":
                 self.display_solo_buttons = True
         if name == "solo_buttons":
             if value == "true":
                 self.display_solo_buttons = True
+                return True
+        if name == 'muted_channels':
+            self._init_muted_channels = value.split('|')
+            return True
+        if name == 'solo_channels':
+            self._init_solo_channels = value.split('|')
+            return True
         return channel.unserialize_property(self, name, value)
 
 def output_channel_serialization_name():
     return "output_channel"
 
 class main_mix(channel):
         return channel.unserialize_property(self, name, value)
 
 def output_channel_serialization_name():
     return "output_channel"
 
 class main_mix(channel):
+    _init_muted_channels = None
+    _init_solo_channels = None
+
     def __init__(self, app):
         channel.__init__(self, app, "MAIN", True)
 
     def __init__(self, app):
         channel.__init__(self, app, "MAIN", True)
 
@@ -609,6 +652,14 @@ class main_mix(channel):
         self.monitor_button.connect('toggled', self.on_monitor_button_toggled)
         self.pack_start(self.monitor_button, False, False)
 
         self.monitor_button.connect('toggled', self.on_monitor_button_toggled)
         self.pack_start(self.monitor_button, False, False)
 
+        for input_channel in self.app.channels:
+            if self._init_muted_channels and input_channel.channel.name in self._init_muted_channels:
+                input_channel.mute.set_active(True)
+            if self._init_solo_channels and input_channel.channel.name in self._init_solo_channels:
+                input_channel.solo.set_active(True)
+        self._init_muted_channels = None
+        self._init_solo_channels = None
+
     def unrealize(self):
         channel.unrealize(self)
         self.channel = False
     def unrealize(self):
         channel.unrealize(self)
         self.channel = False
@@ -616,6 +667,29 @@ class main_mix(channel):
     def serialization_name(self):
         return main_mix_serialization_name()
 
     def serialization_name(self):
         return main_mix_serialization_name()
 
+    def serialize(self, object_backend):
+        muted_channels = []
+        solo_channels = []
+        for input_channel in self.app.channels:
+            if input_channel.channel.mute:
+                muted_channels.append(input_channel)
+            if input_channel.channel.solo:
+                solo_channels.append(input_channel)
+        if muted_channels:
+            object_backend.add_property('muted_channels', '|'.join([x.channel.name for x in muted_channels]))
+        if solo_channels:
+            object_backend.add_property('solo_channels', '|'.join([x.channel.name for x in solo_channels]))
+        channel.serialize(self, object_backend)
+
+    def unserialize_property(self, name, value):
+        if name == 'muted_channels':
+            self._init_muted_channels = value.split('|')
+            return True
+        if name == 'solo_channels':
+            self._init_solo_channels = value.split('|')
+            return True
+        return channel.unserialize_property(self, name, value)
+
 def main_mix_serialization_name():
     return "main_mix_channel"
 
 def main_mix_serialization_name():
     return "main_mix_channel"
 
@@ -835,15 +909,14 @@ class ControlGroup(gtk.Alignment):
         self.add(hbox)
 
         mute = gtk.ToggleButton()
         self.add(hbox)
 
         mute = gtk.ToggleButton()
+        self.mute = mute
         mute.set_label("M")
         mute.set_label("M")
-        #mute.set_active(self.channel.mute)
         mute.connect("toggled", self.on_mute_toggled)
         hbox.pack_start(mute, False)
 
         solo = gtk.ToggleButton()
         self.solo = solo
         solo.set_label("S")
         mute.connect("toggled", self.on_mute_toggled)
         hbox.pack_start(mute, False)
 
         solo = gtk.ToggleButton()
         self.solo = solo
         solo.set_label("S")
-        #solo.set_active(self.channel.solo)
         solo.connect("toggled", self.on_solo_toggled)
         if self.output_channel.display_solo_buttons:
             hbox.pack_start(solo, True)
         solo.connect("toggled", self.on_solo_toggled)
         if self.output_channel.display_solo_buttons:
             hbox.pack_start(solo, True)
index 13e87059f8ae2c8a90e2462b0c2eef09fea1f8bc..58f6c6af69df709ff57cddb5bfff752f3a483a90 100755 (executable)
@@ -168,8 +168,6 @@ class jack_mixer(serialized_object):
         self.scrolled_window.add_with_viewport(self.hbox_inputs)
 
         self.main_mix = main_mix(self)
         self.scrolled_window.add_with_viewport(self.hbox_inputs)
 
         self.main_mix = main_mix(self)
-        self.main_mix.realize()
-        self.main_mix.set_monitored()
         self.hbox_outputs = gtk.HBox()
         self.hbox_outputs.set_spacing(0)
         self.hbox_outputs.set_border_width(0)
         self.hbox_outputs = gtk.HBox()
         self.hbox_outputs.set_spacing(0)
         self.hbox_outputs.set_border_width(0)
@@ -365,10 +363,6 @@ class jack_mixer(serialized_object):
         #self.channel_remove_menu_item.set_sensitive(True)
         self.output_channels.append(channel)
 
         #self.channel_remove_menu_item.set_sensitive(True)
         self.output_channels.append(channel)
 
-        # add group controls to the input channels
-        for inputchannel in self.channels:
-            inputchannel.add_control_group(channel)
-
     _monitored_channel = None
     def get_monitored_channel(self):
         return self._monitored_channel
     _monitored_channel = None
     def get_monitored_channel(self):
         return self._monitored_channel
@@ -410,6 +404,12 @@ class jack_mixer(serialized_object):
                 self.monitor_channel.set_muted(input_channel.channel,
                                 input_channel.channel.mute)
 
                 self.monitor_channel.set_muted(input_channel.channel,
                                 input_channel.channel.mute)
 
+    def get_input_channel_by_name(self, name):
+        for input_channel in self.channels:
+            if input_channel.channel.name == name:
+                return input_channel
+        return None
+
     def on_about(self, *args):
         about = gtk.AboutDialog()
         about.set_name('jack_mixer')
     def on_about(self, *args):
         about = gtk.AboutDialog()
         about.set_name('jack_mixer')
@@ -489,7 +489,8 @@ Franklin Street, Fifth Floor, Boston, MA 02110-130159 USA''')
         for channel in self.unserialized_channels:
             if isinstance(channel, input_channel):
                 self.add_channel_precreated(channel)
         for channel in self.unserialized_channels:
             if isinstance(channel, input_channel):
                 self.add_channel_precreated(channel)
-            else:
+        for channel in self.unserialized_channels:
+            if isinstance(channel, output_channel):
                 self.add_output_channel_precreated(channel)
         del self.unserialized_channels
         self.window.show_all()
                 self.add_output_channel_precreated(channel)
         del self.unserialized_channels
         self.window.show_all()
@@ -528,6 +529,9 @@ Franklin Street, Fifth Floor, Boston, MA 02110-130159 USA''')
         return "jack_mixer"
 
     def main(self):
         return "jack_mixer"
 
     def main(self):
+        self.main_mix.realize()
+        self.main_mix.set_monitored()
+
         if not self.mixer:
             return
 
         if not self.mixer:
             return