Unconditionally save instant.xml on session-close
[ardour.git] / gtk2_ardour / route_group_dialog.cc
index b4da3c19f35e3e21741455c64e207c4fa38ce71f..feca91a8602cc06592eaa9982631738c3cd98f2a 100644 (file)
@@ -1,21 +1,23 @@
 /*
-    Copyright (C) 2009 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
+ * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <iostream>
 
@@ -30,7 +32,7 @@
 #include "group_tabs.h"
 #include "utils.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace Gtk;
 using namespace ARDOUR;
@@ -53,7 +55,6 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
        , _share_color (_("Color"))
        , _share_monitoring (_("Monitoring"))
 {
-       set_modal (true);
        set_skip_taskbar_hint (true);
        set_resizable (true);
        set_name (N_("RouteGroupDialog"));
@@ -85,19 +86,9 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
        hbox->pack_start (*l, false, false);
        hbox->pack_start (_color, false, false);
        top_vbox->pack_start (*hbox, false, false);
-       
-       main_vbox->pack_start (*top_vbox, false, false);
 
-       if (_group->name ().empty()) {
-               _initial_name = "1";
-               while (!unique_name (_initial_name)) {
-                       _initial_name = bump_name_number (_initial_name);
-               }
-               _name.set_text (_initial_name);
-               update();
-       }
+       main_vbox->pack_start (*top_vbox, false, false);
 
-       _name.set_text (_group->name ());
        _active.set_active (_group->is_active ());
 
        Gdk::Color c;
@@ -106,13 +97,11 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
 
        VBox* options_box = manage (new VBox);
        options_box->set_spacing (6);
-       
+
        l = manage (new Label (_("<b>Sharing</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false ));
        l->set_use_markup ();
        options_box->pack_start (*l, false, true);
 
-       _name.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Dialog::response), RESPONSE_OK));
-
        _gain.set_active (_group->is_gain());
        _relative.set_active (_group->is_relative());
        _mute.set_active (_group->is_mute());
@@ -123,19 +112,31 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
        _share_color.set_active (_group->is_color());
        _share_monitoring.set_active (_group->is_monitoring());
 
+       if (_group->name ().empty()) {
+               _initial_name = "1";
+               while (!unique_name (_initial_name)) {
+                       _initial_name = bump_name_number (_initial_name);
+               }
+               _name.set_text (_initial_name);
+               update();
+       } else {
+               _name.set_text (_initial_name);
+       }
+
+       _name.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Dialog::response), RESPONSE_OK));
        _name.signal_changed().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
        _active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
        _color.signal_color_set().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
        _gain.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
-       _relative.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
-       _mute.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
-       _solo.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
-       _rec_enable.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
-       _select.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
-       _route_active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
+       _relative.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
+       _mute.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
+       _solo.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
+       _rec_enable.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
+       _select.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
+       _route_active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
        _share_color.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
        _share_monitoring.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update));
-       
+
        gain_toggled ();
 
        Table* table = manage (new Table (11, 4, false));
@@ -171,43 +172,32 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
                add_button (Stock::CANCEL, RESPONSE_CANCEL);
                add_button (Stock::NEW, RESPONSE_OK);
                set_default_response (RESPONSE_OK);
-       } else {
-               add_button (Stock::CLOSE, RESPONSE_CLOSE);
-               set_default_response (RESPONSE_CLOSE);
        }
 
        show_all_children ();
 }
 
-/** @return true if the route group edit was cancelled, otherwise false */
 bool
-RouteGroupDialog::do_run ()
+RouteGroupDialog::name_check () const
 {
-       while (1) {
-               int const r = run ();
-               if (r == Gtk::RESPONSE_CANCEL) {
-                       /* cancel, so just bail now */
-                       return Gtk::RESPONSE_CANCEL;
-               }
+       if (unique_name (_name.get_text())) {
+               /* not cancelled and the name is ok, so all is well */
+               return true;
+       }
 
-               if (unique_name (_name.get_text())) {
-                       /* not cancelled and the name is ok, so all is well */
-                       return false;
-               }
+       _group->set_name (_initial_name);
 
-               _group->set_name (_initial_name);
-               MessageDialog msg (
-                       _("The group name is not unique. Please use a different name."),
-                       false,
-                       Gtk::MESSAGE_ERROR,
-                       Gtk::BUTTONS_OK,
-                       true
-                       );
+       MessageDialog msg (
+               _("The group name is not unique. Please use a different name."),
+               false,
+               Gtk::MESSAGE_ERROR,
+               Gtk::BUTTONS_OK,
+               true
+               );
 
-               msg.run ();
-       }
+       msg.set_position (WIN_POS_MOUSE);
+       msg.run ();
 
-       /* NOTREACHED */
        return false;
 }
 
@@ -216,20 +206,20 @@ RouteGroupDialog::update ()
 {
        PropertyList plist;
 
-       plist.add (Properties::gain, _gain.get_active());
-       plist.add (Properties::recenable, _rec_enable.get_active());
-       plist.add (Properties::mute, _mute.get_active());
-       plist.add (Properties::solo, _solo.get_active ());
-       plist.add (Properties::select, _select.get_active());
-       plist.add (Properties::route_active, _route_active.get_active());
-       plist.add (Properties::relative, _relative.get_active());
+       plist.add (Properties::group_gain, _gain.get_active());
+       plist.add (Properties::group_recenable, _rec_enable.get_active());
+       plist.add (Properties::group_mute, _mute.get_active());
+       plist.add (Properties::group_solo, _solo.get_active ());
+       plist.add (Properties::group_select, _select.get_active());
+       plist.add (Properties::group_route_active, _route_active.get_active());
+       plist.add (Properties::group_relative, _relative.get_active());
+       plist.add (Properties::group_color, _share_color.get_active());
+       plist.add (Properties::group_monitoring, _share_monitoring.get_active());
        plist.add (Properties::active, _active.get_active());
        plist.add (Properties::name, string (_name.get_text()));
-       plist.add (Properties::color, _share_color.get_active());
-       plist.add (Properties::monitoring, _share_monitoring.get_active());
 
        _group->apply_changes (plist);
-       
+
        GroupTabs::set_group_color (_group, gdk_color_to_rgba (_color.get_color ()));
 }