Add missing files from last commit, as per.
git-svn-id: svn://localhost/ardour2/branches/3.0@5076 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
015fc7b39f
commit
6cf41417a0
1103
gtk2_ardour/rc_option_editor.cc
Normal file
1103
gtk2_ardour/rc_option_editor.cc
Normal file
File diff suppressed because it is too large
Load Diff
19
gtk2_ardour/rc_option_editor.h
Normal file
19
gtk2_ardour/rc_option_editor.h
Normal file
@ -0,0 +1,19 @@
|
||||
#include "option_editor.h"
|
||||
|
||||
/** @file rc_option_editor.h
|
||||
* @brief Editing of options which are obtained from and written back to one of the .rc files.
|
||||
*
|
||||
* This is subclassed from OptionEditor. Simple options (e.g. boolean and simple choices)
|
||||
* are expressed using subclasses of Option. More complex UI elements are represented
|
||||
* using individual classes subclassed rom OptionEditorBox.
|
||||
*/
|
||||
|
||||
/** Editor for options which are obtained from and written back to one of the .rc files. */
|
||||
class RCOptionEditor : public OptionEditor
|
||||
{
|
||||
public:
|
||||
RCOptionEditor ();
|
||||
|
||||
private:
|
||||
ARDOUR::RCConfiguration* _rc_config;
|
||||
};
|
92
libs/ardour/ardour/rc_configuration.h
Normal file
92
libs/ardour/ardour/rc_configuration.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
Copyright (C) 1999 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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __ardour_rc_configuration_h__
|
||||
#define __ardour_rc_configuration_h__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/utils.h"
|
||||
#include "ardour/configuration.h"
|
||||
|
||||
class XMLNode;
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class RCConfiguration : public Configuration
|
||||
{
|
||||
public:
|
||||
RCConfiguration();
|
||||
|
||||
void map_parameters (sigc::slot<void,const char*>);
|
||||
int set_state (XMLNode const &);
|
||||
XMLNode& get_state ();
|
||||
XMLNode& get_variables ();
|
||||
void set_variables (XMLNode const &);
|
||||
|
||||
std::map<std::string, XMLNode> midi_ports;
|
||||
|
||||
int load_state ();
|
||||
int save_state ();
|
||||
|
||||
/// calls Stateful::*instant_xml methods using
|
||||
/// ARDOUR::user_config_directory for the directory argument
|
||||
void add_instant_xml (XMLNode&);
|
||||
XMLNode * instant_xml (const std::string& str);
|
||||
|
||||
XMLNode* control_protocol_state () { return _control_protocol_state; }
|
||||
|
||||
/* define accessor methods */
|
||||
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(Type,var,name,value) \
|
||||
Type get_##var () const { return var.get(); } \
|
||||
bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
|
||||
#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) \
|
||||
Type get_##var () const { return var.get(); } \
|
||||
bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
|
||||
#include "ardour/rc_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
private:
|
||||
|
||||
/* declare variables */
|
||||
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(Type,var,name,value) ConfigVariable<Type> var;
|
||||
#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) ConfigVariableWithMutation<Type> var;
|
||||
#include "ardour/rc_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
XMLNode* _control_protocol_state;
|
||||
};
|
||||
|
||||
/* XXX: rename this */
|
||||
extern RCConfiguration *Config;
|
||||
extern gain_t speed_quietning; /* see comment in configuration.cc */
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
||||
#endif /* __ardour_configuration_h__ */
|
@ -23,9 +23,6 @@ CONFIG_VARIABLE (bool, auto_connect_master, "auto-connect-master", true)
|
||||
CONFIG_VARIABLE (AutoConnectOption, output_auto_connect, "output-auto-connect", AutoConnectOption (0))
|
||||
CONFIG_VARIABLE (AutoConnectOption, input_auto_connect, "input-auto-connect", AutoConnectOption (0))
|
||||
|
||||
CONFIG_VARIABLE (std::string, auditioner_output_left, "auditioner-output-left", "default")
|
||||
CONFIG_VARIABLE (std::string, auditioner_output_right, "auditioner-output-right", "default")
|
||||
|
||||
/* MIDI and MIDI related */
|
||||
|
||||
CONFIG_VARIABLE (std::string, mtc_port_name, "mtc-port-name", "default")
|
||||
@ -57,8 +54,6 @@ CONFIG_VARIABLE (float, midi_readahead, "midi-readahead", 1.0)
|
||||
CONFIG_VARIABLE (float, audio_track_buffer_seconds, "track-buffer-seconds", 5.0)
|
||||
CONFIG_VARIABLE (float, midi_track_buffer_seconds, "midi-track-buffer-seconds", 1.0)
|
||||
CONFIG_VARIABLE (uint32_t, disk_choice_space_threshold, "disk-choice-space-threshold", 57600000)
|
||||
CONFIG_VARIABLE (SampleFormat, native_file_data_format, "native-file-data-format", ARDOUR::FormatFloat)
|
||||
CONFIG_VARIABLE (HeaderFormat, native_file_header_format, "native-file-header-format", ARDOUR::WAVE)
|
||||
CONFIG_VARIABLE (bool, auto_analyse_audio, "auto-analyse-audio", false)
|
||||
|
||||
/* OSC */
|
||||
@ -66,21 +61,9 @@ CONFIG_VARIABLE (bool, auto_analyse_audio, "auto-analyse-audio", false)
|
||||
CONFIG_VARIABLE (uint32_t, osc_port, "osc-port", 3819)
|
||||
CONFIG_VARIABLE (bool, use_osc, "use-osc", false)
|
||||
|
||||
/* fades, crossfades */
|
||||
|
||||
CONFIG_VARIABLE (CrossfadeModel, xfade_model, "xfade-model", FullCrossfade)
|
||||
CONFIG_VARIABLE (bool, auto_xfade, "auto-xfade", true)
|
||||
CONFIG_VARIABLE (float, short_xfade_seconds, "short-xfade-seconds", 0.015)
|
||||
CONFIG_VARIABLE (bool, xfades_active, "xfades-active", true)
|
||||
CONFIG_VARIABLE (bool, xfades_visible, "xfades-visible", true)
|
||||
CONFIG_VARIABLE (uint32_t, destructive_xfade_msecs, "destructive-xfade-msecs", 2)
|
||||
CONFIG_VARIABLE (bool, use_region_fades, "use-region-fades", true)
|
||||
CONFIG_VARIABLE (bool, show_region_fades, "show-region-fades", true)
|
||||
|
||||
/* editing related */
|
||||
|
||||
CONFIG_VARIABLE (EditMode, edit_mode, "edit-mode", Slide)
|
||||
CONFIG_VARIABLE (LayerModel, layer_model, "layer-model", MoveAddHigher)
|
||||
CONFIG_VARIABLE (bool, link_region_and_track_selection, "link-region-and-track-selection", false)
|
||||
CONFIG_VARIABLE (std::string, keyboard_layout_name, "keyboard-layout-name", "ansi")
|
||||
CONFIG_VARIABLE (bool, automation_follows_regions, "automation-follows-regions", false)
|
||||
@ -110,11 +93,6 @@ CONFIG_VARIABLE (std::string, click_emphasis_sound, "click-emphasis-sound", "")
|
||||
|
||||
/* transport control and related */
|
||||
|
||||
CONFIG_VARIABLE (bool, auto_play, "auto-play", false)
|
||||
CONFIG_VARIABLE (bool, auto_return, "auto-return", false)
|
||||
CONFIG_VARIABLE (bool, auto_input, "auto-input", true)
|
||||
CONFIG_VARIABLE (bool, punch_in, "punch-in", false)
|
||||
CONFIG_VARIABLE (bool, punch_out, "punch-out", false)
|
||||
CONFIG_VARIABLE (bool, plugins_stop_with_transport, "plugins-stop-with-transport", false)
|
||||
CONFIG_VARIABLE (bool, do_not_record_plugins, "do-not-record-plugins", false)
|
||||
CONFIG_VARIABLE (bool, stop_recording_on_xrun, "stop-recording-on-xrun", false)
|
||||
@ -138,17 +116,13 @@ CONFIG_VARIABLE (bool, locate_while_waiting_for_sync, "locate-while-waiting-for-
|
||||
/* timecode and sync */
|
||||
|
||||
CONFIG_VARIABLE (bool, jack_time_master, "jack-time-master", true)
|
||||
CONFIG_VARIABLE (SmpteFormat, smpte_format, "smpte-format", smpte_30)
|
||||
CONFIG_VARIABLE (bool, use_video_sync, "use-video-sync", false)
|
||||
CONFIG_VARIABLE (bool, timecode_source_is_synced, "timecode-source-is-synced", true)
|
||||
CONFIG_VARIABLE (float, video_pullup, "video-pullup", 0.0f)
|
||||
|
||||
/* metering */
|
||||
|
||||
CONFIG_VARIABLE (float, meter_hold, "meter-hold", 100.0f)
|
||||
CONFIG_VARIABLE (float, meter_falloff, "meter-falloff", 27.0f)
|
||||
CONFIG_VARIABLE (nframes_t, over_length_short, "over-length-short", 2)
|
||||
CONFIG_VARIABLE (nframes_t, over_length_long, "over-length-long", 10)
|
||||
|
||||
/* miscellany */
|
||||
|
||||
@ -156,7 +130,6 @@ CONFIG_VARIABLE (bool, hiding_groups_deactivates_groups, "hiding-groups-deactiva
|
||||
CONFIG_VARIABLE (bool, verify_remove_last_capture, "verify-remove-last-capture", true)
|
||||
CONFIG_VARIABLE (bool, no_new_session_dialog, "no-new-session-dialog", false)
|
||||
CONFIG_VARIABLE (bool, use_vst, "use-vst", true)
|
||||
CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100)
|
||||
CONFIG_VARIABLE (bool, save_history, "save-history", true)
|
||||
CONFIG_VARIABLE (int32_t, saved_history_depth, "save-history-depth", 20)
|
||||
CONFIG_VARIABLE (int32_t, history_depth, "history-depth", 20)
|
||||
@ -180,12 +153,3 @@ CONFIG_VARIABLE (std::string, default_session_parent_dir, "default-session-paren
|
||||
CONFIG_VARIABLE (bool, denormal_protection, "denormal-protection", false)
|
||||
CONFIG_VARIABLE (DenormalModel, denormal_model, "denormal-model", DenormalNone)
|
||||
|
||||
/* BWAV */
|
||||
|
||||
CONFIG_VARIABLE (std::string, bwf_country_code, "bwf-country-code", "US")
|
||||
CONFIG_VARIABLE (std::string, bwf_organization_code, "bwf-organization-code", "US")
|
||||
|
||||
/* these variables have custom set() methods (e.g. path globbing) */
|
||||
|
||||
CONFIG_VARIABLE_SPECIAL(Glib::ustring, raid_path, "raid-path", "", path_expand)
|
||||
|
69
libs/ardour/ardour/session_configuration.h
Normal file
69
libs/ardour/ardour/session_configuration.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __ardour_session_configuration_h__
|
||||
#define __ardour_session_configuration_h__
|
||||
|
||||
#include "ardour/configuration.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class SessionConfiguration : public Configuration
|
||||
{
|
||||
public:
|
||||
SessionConfiguration ();
|
||||
|
||||
void map_parameters (sigc::slot<void, const char*>);
|
||||
int set_state (XMLNode const &);
|
||||
XMLNode& get_state ();
|
||||
XMLNode& get_variables ();
|
||||
void set_variables (XMLNode const &);
|
||||
|
||||
/* define accessor methods */
|
||||
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(Type,var,name,value) \
|
||||
Type get_##var () const { return var.get(); } \
|
||||
bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
|
||||
#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) \
|
||||
Type get_##var () const { return var.get(); } \
|
||||
bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
|
||||
#include "ardour/session_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
private:
|
||||
|
||||
/* declare variables */
|
||||
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(Type,var,name,value) ConfigVariable<Type> var;
|
||||
#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) ConfigVariableWithMutation<Type> var;
|
||||
#include "ardour/session_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
int foo;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
44
libs/ardour/ardour/session_configuration_vars.h
Normal file
44
libs/ardour/ardour/session_configuration_vars.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
CONFIG_VARIABLE (CrossfadeModel, xfade_model, "xfade-model", FullCrossfade)
|
||||
CONFIG_VARIABLE (bool, auto_xfade, "auto-xfade", true)
|
||||
CONFIG_VARIABLE (float, short_xfade_seconds, "short-xfade-seconds", 0.015)
|
||||
CONFIG_VARIABLE (bool, xfades_active, "xfades-active", true)
|
||||
CONFIG_VARIABLE (bool, xfades_visible, "xfades-visible", true)
|
||||
CONFIG_VARIABLE (uint32_t, destructive_xfade_msecs, "destructive-xfade-msecs", 2)
|
||||
CONFIG_VARIABLE (bool, use_region_fades, "use-region-fades", true)
|
||||
CONFIG_VARIABLE (bool, show_region_fades, "show-region-fades", true)
|
||||
CONFIG_VARIABLE (SampleFormat, native_file_data_format, "native-file-data-format", ARDOUR::FormatFloat)
|
||||
CONFIG_VARIABLE (HeaderFormat, native_file_header_format, "native-file-header-format", ARDOUR::WAVE)
|
||||
CONFIG_VARIABLE (bool, auto_play, "auto-play", false)
|
||||
CONFIG_VARIABLE (bool, auto_return, "auto-return", false)
|
||||
CONFIG_VARIABLE (bool, auto_input, "auto-input", true)
|
||||
CONFIG_VARIABLE (bool, punch_in, "punch-in", false)
|
||||
CONFIG_VARIABLE (bool, punch_out, "punch-out", false)
|
||||
CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100)
|
||||
CONFIG_VARIABLE (SmpteFormat, smpte_format, "smpte-format", smpte_30)
|
||||
CONFIG_VARIABLE_SPECIAL(Glib::ustring, raid_path, "raid-path", "", path_expand)
|
||||
CONFIG_VARIABLE (std::string, bwf_country_code, "bwf-country-code", "US")
|
||||
CONFIG_VARIABLE (std::string, bwf_organization_code, "bwf-organization-code", "US")
|
||||
CONFIG_VARIABLE (bool, end_marker_is_free, "end-marker-is-free", true)
|
||||
CONFIG_VARIABLE (LayerModel, layer_model, "layer-model", MoveAddHigher)
|
||||
CONFIG_VARIABLE (std::string, auditioner_output_left, "auditioner-output-left", "default")
|
||||
CONFIG_VARIABLE (std::string, auditioner_output_right, "auditioner-output-right", "default")
|
||||
CONFIG_VARIABLE (bool, timecode_source_is_synced, "timecode-source-is-synced", true)
|
319
libs/ardour/rc_configuration.cc
Normal file
319
libs/ardour/rc_configuration.cc
Normal file
@ -0,0 +1,319 @@
|
||||
/*
|
||||
Copyright (C) 1999-2006 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.
|
||||
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstdio> /* for snprintf, grrr */
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h> /* for g_stat() */
|
||||
#include <glibmm/miscutils.h>
|
||||
|
||||
#include "pbd/failed_constructor.h"
|
||||
#include "pbd/xml++.h"
|
||||
#include "pbd/filesystem.h"
|
||||
#include "pbd/file_utils.h"
|
||||
|
||||
#include "midi++/manager.h"
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/rc_configuration.h"
|
||||
#include "ardour/audio_diskstream.h"
|
||||
#include "ardour/control_protocol_manager.h"
|
||||
#include "ardour/filesystem_paths.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
using namespace std;
|
||||
using namespace PBD;
|
||||
|
||||
/* this is global so that we do not have to indirect through an object pointer
|
||||
to reference it.
|
||||
*/
|
||||
|
||||
namespace ARDOUR {
|
||||
float speed_quietning = 0.251189; // -12dB reduction for ffwd or rewind
|
||||
}
|
||||
|
||||
RCConfiguration::RCConfiguration ()
|
||||
:
|
||||
/* construct variables */
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(Type,var,name,value) var (name,value),
|
||||
#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) var (name,value,mutator),
|
||||
#include "ardour/rc_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
_control_protocol_state (0)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
RCConfiguration::load_state ()
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
sys::path system_rc_file;
|
||||
struct stat statbuf;
|
||||
|
||||
/* load system configuration first */
|
||||
|
||||
if (find_file_in_search_path (ardour_search_path() + system_config_search_path(),
|
||||
"ardour_system.rc", system_rc_file) )
|
||||
{
|
||||
XMLTree tree;
|
||||
found = true;
|
||||
|
||||
string rcfile = system_rc_file.to_string();
|
||||
|
||||
/* stupid XML Parser hates empty files */
|
||||
|
||||
if (g_stat (rcfile.c_str(), &statbuf)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (statbuf.st_size != 0) {
|
||||
cerr << string_compose (_("Loading system configuration file %1"), rcfile) << endl;
|
||||
|
||||
if (!tree.read (rcfile.c_str())) {
|
||||
error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (set_state (*tree.root())) {
|
||||
error << string_compose(_("Ardour: system configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
error << _("your system Ardour configuration file is empty. This probably means that there as an error installing Ardour") << endmsg;
|
||||
}
|
||||
}
|
||||
|
||||
/* now load configuration file for user */
|
||||
|
||||
sys::path user_rc_file;
|
||||
|
||||
if (find_file_in_search_path (ardour_search_path() + user_config_directory(),
|
||||
"ardour.rc", user_rc_file))
|
||||
{
|
||||
XMLTree tree;
|
||||
found = true;
|
||||
|
||||
string rcfile = user_rc_file.to_string();
|
||||
|
||||
/* stupid XML parser hates empty files */
|
||||
|
||||
if (g_stat (rcfile.c_str(), &statbuf)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (statbuf.st_size != 0) {
|
||||
cerr << string_compose (_("Loading user configuration file %1"), rcfile) << endl;
|
||||
|
||||
if (!tree.read (rcfile)) {
|
||||
error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (set_state (*tree.root())) {
|
||||
error << string_compose(_("Ardour: user configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
warning << _("your Ardour configuration file is empty. This is not normal.") << endmsg;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
error << "Ardour: could not find configuration file (ardour.rc), canvas will look broken." << endmsg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
RCConfiguration::save_state()
|
||||
{
|
||||
XMLTree tree;
|
||||
|
||||
try
|
||||
{
|
||||
sys::create_directories (user_config_directory ());
|
||||
}
|
||||
catch (const sys::filesystem_error& ex)
|
||||
{
|
||||
error << "Could not create user configuration directory" << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
sys::path rcfile_path(user_config_directory());
|
||||
|
||||
rcfile_path /= "ardour.rc";
|
||||
const string rcfile = rcfile_path.to_string();
|
||||
|
||||
// this test seems bogus?
|
||||
if (rcfile.length()) {
|
||||
tree.set_root (&get_state());
|
||||
if (!tree.write (rcfile.c_str())){
|
||||
error << string_compose (_("Config file %1 not saved"), rcfile) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
RCConfiguration::add_instant_xml(XMLNode& node)
|
||||
{
|
||||
Stateful::add_instant_xml (node, user_config_directory ());
|
||||
}
|
||||
|
||||
XMLNode*
|
||||
RCConfiguration::instant_xml(const string& node_name)
|
||||
{
|
||||
return Stateful::instant_xml (node_name, user_config_directory ());
|
||||
}
|
||||
|
||||
|
||||
XMLNode&
|
||||
RCConfiguration::get_state ()
|
||||
{
|
||||
XMLNode* root;
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
root = new XMLNode("Ardour");
|
||||
|
||||
MIDI::Manager::PortMap::const_iterator i;
|
||||
const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
|
||||
|
||||
for (i = ports.begin(); i != ports.end(); ++i) {
|
||||
root->add_child_nocopy(i->second->get_state());
|
||||
}
|
||||
|
||||
root->add_child_nocopy (get_variables ());
|
||||
|
||||
if (_extra_xml) {
|
||||
root->add_child_copy (*_extra_xml);
|
||||
}
|
||||
|
||||
root->add_child_nocopy (ControlProtocolManager::instance().get_state());
|
||||
|
||||
return *root;
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
RCConfiguration::get_variables ()
|
||||
{
|
||||
XMLNode* node;
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
node = new XMLNode ("Config");
|
||||
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(type,var,Name,value) \
|
||||
var.add_to_node (*node);
|
||||
#define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \
|
||||
var.add_to_node (*node);
|
||||
#include "ardour/rc_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
return *node;
|
||||
}
|
||||
|
||||
int
|
||||
RCConfiguration::set_state (const XMLNode& root)
|
||||
{
|
||||
if (root.name() != "Ardour") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
XMLNodeList nlist = root.children();
|
||||
XMLNodeConstIterator niter;
|
||||
XMLNode *node;
|
||||
|
||||
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
|
||||
|
||||
node = *niter;
|
||||
|
||||
if (node->name() == "MIDI-port") {
|
||||
|
||||
try {
|
||||
|
||||
MIDI::Port::Descriptor desc (*node);
|
||||
map<string,XMLNode>::iterator x;
|
||||
if ((x = midi_ports.find (desc.tag)) != midi_ports.end()) {
|
||||
midi_ports.erase (x);
|
||||
}
|
||||
midi_ports.insert (pair<string,XMLNode>(desc.tag,*node));
|
||||
}
|
||||
|
||||
catch (failed_constructor& err) {
|
||||
warning << _("ill-formed MIDI port specification in ardour rcfile (ignored)") << endmsg;
|
||||
}
|
||||
|
||||
} else if (node->name() == "Config") {
|
||||
|
||||
set_variables (*node);
|
||||
|
||||
} else if (node->name() == "Extra") {
|
||||
_extra_xml = new XMLNode (*node);
|
||||
|
||||
} else if (node->name() == ControlProtocolManager::state_node_name) {
|
||||
_control_protocol_state = new XMLNode (*node);
|
||||
}
|
||||
}
|
||||
|
||||
Diskstream::set_disk_io_chunk_frames (minimum_disk_io_bytes.get() / sizeof (Sample));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
RCConfiguration::set_variables (const XMLNode& node)
|
||||
{
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(type,var,name,value) \
|
||||
if (var.set_from_node (node)) { \
|
||||
ParameterChanged (name); \
|
||||
}
|
||||
#define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) \
|
||||
if (var.set_from_node (node)) { \
|
||||
ParameterChanged (name); \
|
||||
}
|
||||
|
||||
#include "ardour/rc_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
}
|
||||
void
|
||||
RCConfiguration::map_parameters (sigc::slot<void,const char*> theSlot)
|
||||
{
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(type,var,name,value) theSlot (name);
|
||||
#define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) theSlot (name);
|
||||
#include "ardour/rc_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
}
|
123
libs/ardour/session_configuration.cc
Normal file
123
libs/ardour/session_configuration.cc
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/utils.h"
|
||||
#include "ardour/session_configuration.h"
|
||||
#include "ardour/ardour.h"
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
SessionConfiguration::SessionConfiguration ()
|
||||
:
|
||||
/* construct variables */
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(Type,var,name,value) var (name,value),
|
||||
#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) var (name,value,mutator),
|
||||
#include "ardour/session_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
foo (0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
SessionConfiguration::get_state ()
|
||||
{
|
||||
XMLNode* root;
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
root = new XMLNode ("Ardour");
|
||||
root->add_child_nocopy (get_variables ());
|
||||
|
||||
return *root;
|
||||
}
|
||||
|
||||
|
||||
XMLNode&
|
||||
SessionConfiguration::get_variables ()
|
||||
{
|
||||
XMLNode* node;
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
node = new XMLNode ("Config");
|
||||
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(type,var,Name,value) \
|
||||
var.add_to_node (*node);
|
||||
#define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \
|
||||
var.add_to_node (*node);
|
||||
#include "ardour/session_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
return *node;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SessionConfiguration::set_state (XMLNode const& root)
|
||||
{
|
||||
if (root.name() != "Ardour") {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (XMLNodeConstIterator i = root.children().begin(); i != root.children().end(); ++i) {
|
||||
if ((*i)->name() == "Config") {
|
||||
set_variables (**i);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SessionConfiguration::set_variables (const XMLNode& node)
|
||||
{
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(type,var,name,value) \
|
||||
if (var.set_from_node (node)) { \
|
||||
ParameterChanged (name); \
|
||||
}
|
||||
#define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) \
|
||||
if (var.set_from_node (node)) { \
|
||||
ParameterChanged (name); \
|
||||
}
|
||||
|
||||
#include "ardour/session_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
}
|
||||
void
|
||||
SessionConfiguration::map_parameters (sigc::slot<void,const char*> theSlot)
|
||||
{
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(type,var,name,value) theSlot (name);
|
||||
#define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) theSlot (name);
|
||||
#include "ardour/session_configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
}
|
Loading…
Reference in New Issue
Block a user