]> git.0d.be Git - jack_mixer.git/commitdiff
Ability to widen/narrow input channels.
authorDaniel Sheeler <dsheeler@pobox.com>
Wed, 22 Jul 2020 06:07:52 +0000 (01:07 -0500)
committerDaniel Sheeler <dsheeler@pobox.com>
Wed, 22 Jul 2020 06:07:52 +0000 (01:07 -0500)
Narrow removes control group labels, but could do more.
Control-click on label toggles wide/narrow state.
Added menu items to widen/narrow all channels.

channel.py
jack_mixer.py

index c6306831fb8ecb54e6d73bd7560c530269f9bea2..6ece2c4ec79da41253bbdebbe12bac3e7da21467 100644 (file)
@@ -36,7 +36,7 @@ except:
 log = logging.getLogger(__name__)
 button_padding = 1
 css = b"""
-.top_label {min-width: 100px;}
+.top_label {padding: 0px .1em}
 button {padding: 0px}
 """
 css_provider = Gtk.CssProvider()
@@ -429,6 +429,7 @@ class InputChannel(Channel):
 
     def __init__(self, app, name, stereo, value = None):
         Channel.__init__(self, app, name, stereo, value)
+        self.wide = True
 
     def realize(self):
         self.channel = self.mixer.add_channel(self.channel_name, self.stereo)
@@ -522,6 +523,19 @@ class InputChannel(Channel):
         self.monitor_button = Gtk.ToggleButton('MON')
         self.monitor_button.connect('toggled', self.on_monitor_button_toggled)
         self.pack_start(self.monitor_button, False, False, 0)
+        if not self.wide:
+            self.narrow()
+
+
+    def narrow(self):
+        for cg in self.get_control_groups():
+            cg.narrow()
+        self.wide = False
+
+    def widen(self):
+        for cg in self.get_control_groups():
+            cg.widen()
+        self.wide = True
 
     def on_drag_data_get(self, widget, drag_context, data, info, time):
         channel = widget.get_parent().get_parent()
@@ -550,12 +564,18 @@ class InputChannel(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
+        for control_group in self.get_control_groups:
+            if control_group.output_channel is channel:
+                return control_group
         return None
 
+    def get_control_groups(self):
+        ctlgroups = []
+        for c in self.vbox.get_children():
+            if isinstance(c, ControlGroup):
+                ctlgroups.append(c)
+        return ctlgroups
+
     def unrealize(self):
         Channel.unrealize(self)
         if self.post_fader_output_channel:
@@ -576,6 +596,13 @@ class InputChannel(Channel):
         if event.type == Gdk.EventType._2BUTTON_PRESS:
             if event.button == 1:
                 self.on_channel_properties()
+            return True
+        elif event.state & Gdk.ModifierType.CONTROL_MASK and event.type == Gdk.EventType.BUTTON_PRESS and event.button == 1:
+            if self.wide:
+                self.narrow()
+            else:
+                self.widen()
+            return True
 
     def on_mute_toggled(self, button):
         self.channel.out_mute = self.mute.get_active()
@@ -618,6 +645,7 @@ class InputChannel(Channel):
 
     def serialize(self, object_backend):
         object_backend.add_property("name", self.channel_name)
+        object_backend.add_property("wide", "%s" % str(self.wide))
         if self.stereo:
             object_backend.add_property("type", "stereo")
         else:
@@ -628,6 +656,9 @@ class InputChannel(Channel):
         if name == "name":
             self.channel_name = str(value)
             return True
+        if name == "wide":
+            self.wide = value == "True"
+            return True
         if name == "type":
             if value == "stereo":
                 self.stereo = True
@@ -740,13 +771,16 @@ class OutputChannel(Channel):
         # 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)
+            input_channel.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)
+                input_channel.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)
+                input_channel.ctlgroup.solo.set_active(True)
             if self._init_prefader_channels and input_channel.channel.name in self._init_prefader_channels:
-                ctlgroup.prefader.set_active(True)
+                input_channel.ctlgroup.prefader.set_active(True)
+            if not input_channel.wide:
+                input_channel.ctlgroup.narrow()
+
         self._init_muted_channels = None
         self._init_solo_channels = None
         self._init_prefader_channels = None
@@ -1249,3 +1283,11 @@ class ControlGroup(Gtk.Alignment):
 
     def on_prefader_toggled(self, button):
         self.output_channel.channel.set_in_prefader(self.input_channel.channel, button.get_active())
+
+    def narrow(self):
+        self.hbox.remove(self.label)
+        self.hbox.set_child_packing(self.buttons_box, True, True, button_padding, Gtk.PackType.END)
+
+    def widen(self):
+        self.hbox.pack_start(self.label, False, False, button_padding)
+        self.hbox.set_child_packing(self.buttons_box, False, False, button_padding, Gtk.PackType.END)
index fea0a3b8ed2e755e07b1eb8d8c20db5a7f3e4a00..01ec7a049c38832baeee6b76fd87ddec3eb70f20 100755 (executable)
@@ -188,6 +188,11 @@ class JackMixer(SerializedObject):
         self.channel_remove_output_menu = Gtk.Menu()
         self.channel_remove_output_menu_item.set_submenu(self.channel_remove_output_menu)
 
+        edit_menu.append(Gtk.SeparatorMenuItem())
+        edit_menu.append(self.new_menu_item('Narrow Input Channels', self.on_narrow_input_channels_cb, "<Control>A"))
+        edit_menu.append(self.new_menu_item('Widen Input Channels', self.on_widen_input_channels_cb, "<Control>W"))
+        edit_menu.append(Gtk.SeparatorMenuItem())
+
         edit_menu.append(self.new_menu_item('_Clear', self.on_channels_clear, "<Control>X"))
         edit_menu.append(Gtk.SeparatorMenuItem())
         edit_menu.append(self.new_menu_item('_Preferences', self.on_preferences_cb, "<Control>P"))
@@ -329,6 +334,14 @@ class JackMixer(SerializedObject):
     def on_quit_cb(self, *args):
         Gtk.main_quit()
 
+    def on_narrow_input_channels_cb(self, widget):
+        for channel in self.channels:
+            channel.narrow()
+
+    def on_widen_input_channels_cb(self, widget):
+        for channel in self.channels:
+            channel.widen()
+
     preferences_dialog = None
     def on_preferences_cb(self, widget):
         if not self.preferences_dialog:
@@ -728,7 +741,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-130159 USA''')
             self.window.show_all()
         self.paned.set_position(self.paned_position/self.width*width)
         self.window.resize(self.width, self.height)
+
     def serialize(self, object_backend):
         width, height = self.window.get_size()
         object_backend.add_property('geometry',