Add option to set default-session-parent-dir (#4438).
authorCarl Hetherington <carl@carlh.net>
Fri, 4 Nov 2011 15:05:49 +0000 (15:05 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 4 Nov 2011 15:05:49 +0000 (15:05 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10435 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/option_editor.cc
gtk2_ardour/option_editor.h
gtk2_ardour/rc_option_editor.cc

index 33f8a8dc43ef58b461d43bbfd01bc3b533e0bca6..770df4d37dc8db1853105b833a61d156b61eab0c 100644 (file)
@@ -320,4 +320,30 @@ OptionEditor::set_current_page (string const & p)
 }
 
 
+DirectoryOption::DirectoryOption (string const & i, string const & n, sigc::slot<string> g, sigc::slot<bool, string> 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 ());
+}
index f43f71342bb98a8efb605472d46e05fe0a405945..f3f2164c77cb09af3909e3c33acac8bf820665c8 100644 (file)
@@ -377,6 +377,22 @@ private:
        sigc::slot<bool, ARDOUR::framecnt_t> _set;
 };
 
+class DirectoryOption : public Option
+{
+public:
+       DirectoryOption (std::string const &, std::string const &, sigc::slot<std::string>, sigc::slot<bool, std::string>);
+
+       void set_state_from_config ();
+       void add_to_page (OptionEditorPage *);
+
+private:
+       void file_set ();
+       
+       sigc::slot<std::string> _get; ///< slot to get the configuration variable's value
+       sigc::slot<bool, std::string> _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.
index 17d14f9d6099d4034a0f16c71d2946469b5631b6..d4b9d4fc5093615a733e95191ff09c003ded4c30 100644 (file)
@@ -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));