From b02673adb47e578284d91445b108ee256149ce1f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 4 Nov 2011 15:05:49 +0000 Subject: [PATCH] Add option to set default-session-parent-dir (#4438). git-svn-id: svn://localhost/ardour2/branches/3.0@10435 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/option_editor.cc | 26 ++++++++++++++++++++++++++ gtk2_ardour/option_editor.h | 16 ++++++++++++++++ gtk2_ardour/rc_option_editor.cc | 7 +++++++ 3 files changed, 49 insertions(+) diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index 33f8a8dc43..770df4d37d 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -320,4 +320,30 @@ OptionEditor::set_current_page (string const & p) } +DirectoryOption::DirectoryOption (string const & i, string const & n, sigc::slot g, sigc::slot s) + : Option (i, n) + , _get (g) + , _set (s) +{ + _file_chooser.set_action (Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); + _file_chooser.signal_file_set().connect (sigc::mem_fun (*this, &DirectoryOption::file_set)); +} + +void +DirectoryOption::set_state_from_config () +{ + _file_chooser.set_filename (_get ()); +} + +void +DirectoryOption::add_to_page (OptionEditorPage* p) +{ + add_widgets_to_page (p, manage (new Label (_name)), &_file_chooser); +} + +void +DirectoryOption::file_set () +{ + _set (_file_chooser.get_filename ()); +} diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h index f43f71342b..f3f2164c77 100644 --- a/gtk2_ardour/option_editor.h +++ b/gtk2_ardour/option_editor.h @@ -377,6 +377,22 @@ private: sigc::slot _set; }; +class DirectoryOption : public Option +{ +public: + DirectoryOption (std::string const &, std::string const &, sigc::slot, sigc::slot); + + void set_state_from_config (); + void add_to_page (OptionEditorPage *); + +private: + void file_set (); + + sigc::slot _get; ///< slot to get the configuration variable's value + sigc::slot _set; ///< slot to set the configuration variable's value + Gtk::FileChooserButton _file_chooser; +}; + /** Class to represent a single page in an OptionEditor's notebook. * Pages are laid out using a 3-column table; the 1st column is used * to indent non-headings, and the 2nd and 3rd for actual content. diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 17d14f9d60..d4b9d4fc50 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -908,6 +908,13 @@ RCOptionEditor::RCOptionEditor () sigc::mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files) )); + add_option (_("Misc"), new DirectoryOption ( + X_("default-session-parent-dir"), + _("Default folder for new sessions:"), + sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_session_parent_dir), + sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_session_parent_dir) + )); + add_option (_("Misc"), new OptionEditorHeading (_("Click"))); add_option (_("Misc"), new ClickOptions (_rc_config, this));