use home-grown solution for path_expand(), rather than wordexp() which is broken...
[ardour.git] / gtk2_ardour / startup.cc
index 1714364fd3fab88d106eb5c31f7fbb925620d421..77afb0fa1757dc3714221f12f86d4afa004a7ffb 100644 (file)
@@ -102,17 +102,43 @@ Ardour will play NO role in monitoring"))
                throw failed_constructor();
        }
 
-       sys::path been_here_before = user_config_directory();
-       been_here_before /= ".a3"; // XXXX use more specific version so we can catch upgrades
-       new_user = !exists (been_here_before);
+       list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
+       Glib::RefPtr<Gdk::Pixbuf> icon;
+
+       if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
+               window_icons.push_back (icon);
+       }
+       if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
+               window_icons.push_back (icon);
+       }
+       if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
+               window_icons.push_back (icon);
+       }
+       if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
+               window_icons.push_back (icon);
+       }
+       if (!window_icons.empty ()) {
+               set_default_icon_list (window_icons);
+       }
+
+       new_user = !exists (been_here_before_path ());
 
        bool need_audio_setup = !EngineControl::engine_running();
 
         setup_alpha_page ();
 
        if (new_user) {
-               /* "touch" the file */
-               ofstream fout (been_here_before.to_string().c_str());
+
+               /* Create the config directory so that we have somewhere to put the
+                  been_here_before file.
+               */
+               try {
+                       sys::create_directories (user_config_directory ());
+               }
+               catch (const sys::filesystem_error& ex) {
+                       error << "Could not create user configuration directory" << endmsg;
+               }
+               
                setup_new_user_page ();
                setup_first_time_config_page ();
                setup_monitoring_choice_page ();
@@ -337,7 +363,7 @@ using the program.</span>\
 void
 ArdourStartup::default_dir_changed ()
 {
-       Config->set_default_session_parent_dir (default_dir_chooser->get_current_folder());
+       Config->set_default_session_parent_dir (default_dir_chooser->get_filename());
        config_changed ();
 }
 
@@ -604,7 +630,7 @@ ArdourStartup::on_apply ()
        if (config_modified) {
 
                if (default_dir_chooser) {
-                       Config->set_default_session_parent_dir (default_dir_chooser->get_current_folder());
+                       Config->set_default_session_parent_dir (default_dir_chooser->get_filename());
                }
 
                if (monitor_via_hardware_button.get_active()) {
@@ -615,6 +641,9 @@ ArdourStartup::on_apply ()
 
                Config->set_use_monitor_bus (use_monitor_section_button.get_active());
 
+               /* "touch" the been-here-before path now that we're about to save Config */
+               ofstream fout (been_here_before_path().to_string().c_str());
+               
                Config->save_state ();
        }
 
@@ -633,6 +662,26 @@ ArdourStartup::on_prepare (Gtk::Widget* page)
                } else {
                        /* existing session requested */
                        setup_existing_session_page ();
+
+               }
+
+               /* HACK HACK HACK ... change the "Apply" button label
+                  to say "Open"
+               */
+
+               Gtk::Widget* tl = session_vbox.get_toplevel();
+               Gtk::Window* win;
+               if ((win = dynamic_cast<Gtk::Window*>(tl)) != 0) {
+                       /* ::get_default_widget() is not wrapped in gtkmm */
+                       Gtk::Widget* def = wrap (gtk_window_get_default_widget (win->gobj()));
+                       Gtk::Button* button;
+                       if ((button = dynamic_cast<Gtk::Button*>(def)) != 0) {
+                               if (more_new_session_options_button.get_active()) {
+                                       button->set_label (_("Forward"));
+                               }else{
+                                       button->set_label (_("Open"));
+                               }
+                       }
                }
        }
 }
@@ -817,6 +866,10 @@ ArdourStartup::setup_new_session_page ()
        set_page_title (session_vbox, _("New Session"));
        set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM);
 
+       if (more_new_session_options_button.get_active()) {
+               set_page_type (session_vbox, ASSISTANT_PAGE_CONTENT);
+       }
+
        new_name_entry.signal_map().connect (sigc::mem_fun (*this, &ArdourStartup::new_name_mapped));
        new_name_entry.signal_focus_out_event().connect (sigc::ptr_fun (lost_name_entry_focus));
 }
@@ -1050,7 +1103,7 @@ ArdourStartup::setup_more_options_page ()
        _connect_inputs.set_flags(Gtk::CAN_FOCUS);
        _connect_inputs.set_relief(Gtk::RELIEF_NORMAL);
        _connect_inputs.set_mode(true);
-       _connect_inputs.set_active(true);
+       _connect_inputs.set_active(Config->get_input_auto_connect() != ManualConnect);
        _connect_inputs.set_border_width(0);
 
        _limit_input_ports.set_label (_("Use only"));
@@ -1110,7 +1163,7 @@ ArdourStartup::setup_more_options_page ()
        _connect_outputs.set_flags(Gtk::CAN_FOCUS);
        _connect_outputs.set_relief(Gtk::RELIEF_NORMAL);
        _connect_outputs.set_mode(true);
-       _connect_outputs.set_active(true);
+       _connect_outputs.set_active(Config->get_output_auto_connect() != ManualConnect);
        _connect_outputs.set_border_width(0);
        _limit_output_ports.set_label (_("Use only"));
        _limit_output_ports.set_flags(Gtk::CAN_FOCUS);
@@ -1132,7 +1185,7 @@ ArdourStartup::setup_more_options_page ()
        _connect_outputs_to_master.set_flags(Gtk::CAN_FOCUS);
        _connect_outputs_to_master.set_relief(Gtk::RELIEF_NORMAL);
        _connect_outputs_to_master.set_mode(true);
-       _connect_outputs_to_master.set_active(false);
+       _connect_outputs_to_master.set_active(Config->get_output_auto_connect() == AutoConnectMaster);
        _connect_outputs_to_master.set_border_width(0);
 
        _connect_outputs_to_master.set_group (connect_outputs_group);
@@ -1142,7 +1195,7 @@ ArdourStartup::setup_more_options_page ()
        _connect_outputs_to_physical.set_flags(Gtk::CAN_FOCUS);
        _connect_outputs_to_physical.set_relief(Gtk::RELIEF_NORMAL);
        _connect_outputs_to_physical.set_mode(true);
-       _connect_outputs_to_physical.set_active(false);
+       _connect_outputs_to_physical.set_active(Config->get_output_auto_connect() == AutoConnectPhysical);
        _connect_outputs_to_physical.set_border_width(0);
 
        output_conn_vbox.pack_start(_connect_outputs, Gtk::PACK_SHRINK, 0);
@@ -1324,3 +1377,12 @@ ArdourStartup::existing_session_selected ()
        set_page_complete (session_vbox, true);
        move_along_now ();
 }
+
+sys::path
+ArdourStartup::been_here_before_path () const
+{
+       sys::path b = user_config_directory();
+       b /= ".a3"; // XXXX use more specific version so we can catch upgrades
+       return b;
+}
+