]> git.0d.be Git - jack_mixer.git/blobdiff - jack_mixer.py
Set version to 14 in preparation for next release
[jack_mixer.git] / jack_mixer.py
index 5238e86e613c074bb3d7493d86dd9d0162651c6a..3c13d4abc02f5c267cefe098b661383b439cdbf5 100755 (executable)
@@ -217,8 +217,8 @@ class JackMixer(SerializedObject):
         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('Shrink Input Channels', self.on_narrow_input_channels_cb, "<Control>minus"))
-        edit_menu.append(self.new_menu_item('Expand Input Channels', self.on_widen_input_channels_cb, "<Control>plus"))
+        edit_menu.append(self.new_menu_item('Shrink Channels', self.on_shrink_channels_cb, "<Control>minus"))
+        edit_menu.append(self.new_menu_item('Expand Channels', self.on_expand_channels_cb, "<Control>plus"))
         edit_menu.append(Gtk.SeparatorMenuItem())
 
         edit_menu.append(self.new_menu_item('_Clear', self.on_channels_clear, "<Control>X"))
@@ -277,12 +277,13 @@ class JackMixer(SerializedObject):
         self.create_mixer(client_name, with_nsm=True)
         self.current_filename = path + '.xml'
         if os.path.isfile(self.current_filename):
-            f = open(self.current_filename, 'r')
-            self.load_from_xml(f, from_nsm=True)
-            f.close()
-        else:
-            f = open(self.current_filename, 'w')
-            f.close()
+            try:
+                with open(self.current_filename, 'r') as fp:
+                    self.load_from_xml(fp, from_nsm=True)
+            except Exception as exc:
+                # Re-raise with more meaningful error message
+                raise IOError("Error loading settings file '{}': {}".format(
+                              self.current_filename, exc))
 
     def nsm_save_cb(self, path, session_name, client_name):
         self.current_filename = path + '.xml'
@@ -333,14 +334,12 @@ class JackMixer(SerializedObject):
         if dlg.run() == Gtk.ResponseType.OK:
             filename = dlg.get_filename()
             try:
-                f = open(filename, 'r')
-                self.load_from_xml(f)
-            except Exception as e:
-                error_dialog(self.window, "Failed loading settings (%s)", e)
+                with open(filename, 'r') as fp:
+                    self.load_from_xml(fp)
+            except Exception as exc:
+                error_dialog(self.window, "Error loading settings file '%s': %s", filename, exc)
             else:
                 self.current_filename = filename
-            finally:
-                f.close()
         dlg.destroy()
 
     def on_save_cb(self, *args):
@@ -381,12 +380,12 @@ class JackMixer(SerializedObject):
 
         Gtk.main_quit()
 
-    def on_narrow_input_channels_cb(self, widget):
-        for channel in self.channels:
+    def on_shrink_channels_cb(self, widget):
+        for channel in self.channels + self.output_channels:
             channel.narrow()
 
-    def on_widen_input_channels_cb(self, widget):
-        for channel in self.channels:
+    def on_expand_channels_cb(self, widget):
+        for channel in self.channels + self.output_channels:
             channel.widen()
 
     preferences_dialog = None
@@ -800,6 +799,14 @@ Franklin Street, Fifth Floor, Boston, MA 02110-130159 USA""")
         width, height = self.window.get_size()
         if self.visible or not from_nsm:
             self.window.show_all()
+
+        if self.output_channels:
+            self.output_channels[-1].volume_digits.select_region(0,0)
+            self.output_channels[-1].slider.grab_focus()
+        elif self.channels:
+            self.channels[-1].volume_digits.select_region(0,0)
+            self.channels[-1].volume_digits.grab_focus()
+
         self.paned.set_position(self.paned_position/self.width*width)
         self.window.resize(self.width, self.height)
 
@@ -894,20 +901,19 @@ def main():
     try:
         mixer = JackMixer(args.client_name)
     except Exception as e:
-        error_dialog(None, "Mixer creation failed (%s).", e)
+        error_dialog(None, "Mixer creation failed:\n\n%s", e)
         sys.exit(1)
 
     if not mixer.nsm_client and args.config:
-        f = open(args.config)
-        mixer.current_filename = args.config
-
         try:
-            mixer.load_from_xml(f)
-        except Exception as e:
-            error_dialog(mixer.window, "Failed loading settings (%s).", e)
+            with open(args.config) as fp:
+                mixer.load_from_xml(fp)
+        except Exception as exc:
+            error_dialog(mixer.window, "Error loading settings file '%s': %s", args.config, exc)
+        else:
+            mixer.current_filename = args.config
 
         mixer.window.set_default_size(60*(1+len(mixer.channels)+len(mixer.output_channels)), 300)
-        f.close()
 
     mixer.main()