X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmissing_file_dialog.cc;h=89ef01c372eb6e42d5b4de62219e5480d7452e4c;hb=52a2f5bada673602b8432254286ab17d19a68515;hp=37868d55728569b4bdf159633e9fb7527f031e9f;hpb=a882e96db1367c26660fd3d3079e9e3e19b1e149;p=ardour.git diff --git a/gtk2_ardour/missing_file_dialog.cc b/gtk2_ardour/missing_file_dialog.cc index 37868d5572..89ef01c372 100644 --- a/gtk2_ardour/missing_file_dialog.cc +++ b/gtk2_ardour/missing_file_dialog.cc @@ -22,9 +22,10 @@ #include "pbd/search_path.h" #include "ardour/session.h" +#include "gtkmm2ext/utils.h" #include "missing_file_dialog.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace Gtk; using namespace std; @@ -32,30 +33,34 @@ using namespace ARDOUR; using namespace PBD; MissingFileDialog::MissingFileDialog (Session* s, const std::string& path, DataType type) - : ArdourDialog (_("Missing File!"), true, false) - , filetype (type) - , chooser (_("Select a folder to search"), FILE_CHOOSER_ACTION_SELECT_FOLDER) - , use_chosen (_("Add chosen folder to search path, and try again")) - , choice_group (use_chosen.get_group()) - , stop_loading_button (choice_group, _("Stop loading this session"), false) - , all_missing_ok (choice_group, _("Skip all missing files"), false) - , this_missing_ok (choice_group, _("Skip this file"), false) + : ArdourDialog (_("Missing File"), true, false) + , filetype (type) + , is_absolute_path (Glib::path_is_absolute (path)) + , chooser (_("Select a folder to search"), FILE_CHOOSER_ACTION_SELECT_FOLDER) + , use_chosen (_("Add chosen folder to search path, and try again")) + , choice_group (use_chosen.get_group()) + , stop_loading_button (choice_group, _("Stop loading this session"), false) + , all_missing_ok (choice_group, _("Skip all missing files"), false) + , this_missing_ok (choice_group, _("Skip this file"), false) { - set_session (s); + /* This dialog is always shown programatically. Center the window.*/ + set_position (Gtk::WIN_POS_CENTER); - add_button (_("Done"), RESPONSE_OK); - set_default_response (RESPONSE_OK); + set_session (s); - string typestr; + add_button (_("Done"), RESPONSE_OK); + set_default_response (RESPONSE_OK); - switch (type) { - case DataType::AUDIO: - typestr = _("audio"); - break; - case DataType::MIDI: - typestr = _("MIDI"); - break; - } + string typestr; + + switch (type) { + case DataType::AUDIO: + typestr = _("audio"); + break; + case DataType::MIDI: + typestr = _("MIDI"); + break; + } vector source_dirs = s->source_search_path (type); vector::iterator i = source_dirs.begin(); @@ -66,114 +71,124 @@ MissingFileDialog::MissingFileDialog (Session* s, const std::string& path, DataT oss << *i << endl; } - msg.set_justify (JUSTIFY_CENTER); - msg.set_markup (string_compose (_("%1 cannot find the %2 file\n\n%3\n\nin any of these folders:\n\n\ -%4\n\n"), PROGRAM_NAME, typestr, Glib::Markup::escape_text(path), Glib::Markup::escape_text (oss.str()))); + msg.set_justify (JUSTIFY_LEFT); + msg.set_markup (string_compose (_("%1 cannot find the %2 file\n\n%3\n\nin any of these folders:\n\n\ + %4\n\n"), PROGRAM_NAME, typestr, Gtkmm2ext::markup_escape_text (path), Gtkmm2ext::markup_escape_text (oss.str()))); - HBox* hbox = manage (new HBox); - hbox->pack_start (msg, false, true); - hbox->show (); + HBox* hbox = manage (new HBox); + hbox->pack_start (msg, false, true); + hbox->show (); - get_vbox()->pack_start (*hbox, false, false); + get_vbox()->pack_start (*hbox, false, false); - VBox* button_packer_box = manage (new VBox); + VBox* button_packer_box = manage (new VBox); - button_packer_box->set_spacing (6); - button_packer_box->set_border_width (12); + button_packer_box->set_spacing (6); + button_packer_box->set_border_width (12); - button_packer_box->pack_start (use_chosen, false, false); - button_packer_box->pack_start (this_missing_ok, false, false); - button_packer_box->pack_start (all_missing_ok, false, false); - button_packer_box->pack_start (stop_loading_button, false, false); + button_packer_box->pack_start (use_chosen, false, false); + button_packer_box->pack_start (this_missing_ok, false, false); + button_packer_box->pack_start (all_missing_ok, false, false); + button_packer_box->pack_start (stop_loading_button, false, false); - button_packer_box->show_all (); + button_packer_box->show_all (); - get_vbox()->set_spacing (6); - get_vbox()->set_border_width (25); - get_vbox()->set_homogeneous (false); + get_vbox()->set_spacing (6); + get_vbox()->set_border_width (25); + get_vbox()->set_homogeneous (false); - hbox = manage (new HBox); - hbox->pack_start (*button_packer_box, false, true); - hbox->show (); + hbox = manage (new HBox); + hbox->pack_start (*button_packer_box, false, true); + hbox->show (); - get_vbox()->pack_start (*hbox, false, false); + get_vbox()->pack_start (*hbox, false, false); - hbox = manage (new HBox); - Label* label = manage (new Label); - label->set_text (_("Click to choose an additional folder")); + hbox = manage (new HBox); + Label* label = manage (new Label); + label->set_text (_("Click to choose an additional folder")); - hbox->set_spacing (6); - hbox->set_border_width (12); - hbox->pack_start (*label, false, false); - hbox->pack_start (chooser, true, true); - hbox->show_all (); + hbox->set_spacing (6); + hbox->set_border_width (12); + hbox->pack_start (*label, false, false); + hbox->pack_start (chooser, true, true); + hbox->show_all (); - get_vbox()->pack_start (*hbox, true, true); + get_vbox()->pack_start (*hbox, true, true); - msg.show (); + msg.show (); - chooser.set_current_folder (Glib::get_home_dir()); - chooser.set_create_folders (false); + chooser.set_current_folder (Glib::get_home_dir()); + chooser.set_create_folders (false); +} + +void +MissingFileDialog::set_absolute () +{ + _session->set_missing_file_replacement (chooser.get_filename ()); } void MissingFileDialog::add_chosen () { - string str; - string newdir; - vector dirs; - - switch (filetype) { - case DataType::AUDIO: - str = _session->config.get_audio_search_path(); - break; - case DataType::MIDI: - str = _session->config.get_midi_search_path(); - break; - } - - split (str, dirs, ':'); - - newdir = chooser.get_filename (); - - for (vector::iterator d = dirs.begin(); d != dirs.end(); d++) { - if (*d == newdir) { - return; - } - } - - if (!str.empty()) { - str += ':'; - } - - str += newdir; - - switch (filetype) { - case DataType::AUDIO: - _session->config.set_audio_search_path (str); - break; - case DataType::MIDI: - _session->config.set_midi_search_path (str); - break; - } + string str; + string newdir; + vector dirs; + + switch (filetype) { + case DataType::AUDIO: + str = _session->config.get_audio_search_path(); + break; + case DataType::MIDI: + str = _session->config.get_midi_search_path(); + break; + } + + split (str, dirs, G_SEARCHPATH_SEPARATOR); + + newdir = chooser.get_filename (); + + for (vector::iterator d = dirs.begin(); d != dirs.end(); d++) { + if (*d == newdir) { + return; + } + } + + if (!str.empty()) { + str += G_SEARCHPATH_SEPARATOR; + } + + str += newdir; + + switch (filetype) { + case DataType::AUDIO: + _session->config.set_audio_search_path (str); + break; + case DataType::MIDI: + _session->config.set_midi_search_path (str); + break; + } } int MissingFileDialog::get_action () { - if (use_chosen.get_active ()) { - add_chosen (); - return 0; - } + if (use_chosen.get_active ()) { + if (is_absolute_path) { + set_absolute (); + } else { + add_chosen (); + } + return 0; + } - if (this_missing_ok.get_active()) { - return -1; - } + if (this_missing_ok.get_active()) { + return -1; + } - if (all_missing_ok.get_active ()) { - return 3; - } + if (all_missing_ok.get_active ()) { + return 3; + } - return 1; + return 1; }