Fix a couple of issues when displaying the 'Preferences' dialog on Windows:-
authorJohn Emmas <johne53@tiscali.co.uk>
Mon, 9 Mar 2015 15:54:59 +0000 (15:54 +0000)
committerJohn Emmas <johne53@tiscali.co.uk>
Mon, 9 Mar 2015 15:57:15 +0000 (15:57 +0000)
1) When changing the 'Default folder for new sessions' we weren't responding to the appropriate signal (so the change wasn't getting saved in our user's 'config' file). We now respond to the 'selection-changed' signal.

2) If the above path happened to contain a tilde character we weren't interpreting it to mean the user's home folder. I've copied across a function called 'poor_mans_glob()' which Ardour uses elsewhere for dealing with this situation in other file dialogs.

Once we confirm that issue #2 is now working for all platforms, I'd suggest moving 'poor_mans_glob()' into libpbd. At the moment we have at least 3 definitions of it (all identical) scattered around in various places.

gtk2_ardour/option_editor.cc
gtk2_ardour/option_editor.h

index daf163eb0825d3eb261686274ab1c87164ffbbbe..a7fb86deda4138505349b1e59439d79eb7486b54 100644 (file)
@@ -29,6 +29,7 @@
 #include "ardour/utils.h"
 
 #include "pbd/configuration.h"
+#include "pbd/replace_all.h"
 
 #include "public_editor.h"
 #include "option_editor.h"
@@ -40,6 +41,13 @@ using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace ARDOUR;
 
+static string poor_mans_glob (string path)
+{
+       string copy = path;
+       replace_all (copy, "~", Glib::get_home_dir());
+       return copy;
+}
+
 void
 OptionEditorComponent::add_widget_to_page (OptionEditorPage* p, Gtk::Widget* w)
 {
@@ -483,7 +491,7 @@ DirectoryOption::DirectoryOption (string const & i, string const & n, sigc::slot
        , _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));
+       _file_chooser.signal_selection_changed().connect (sigc::mem_fun (*this, &DirectoryOption::selection_changed));
        _file_chooser.signal_current_folder_changed().connect (sigc::mem_fun (*this, &DirectoryOption::current_folder_set));
 }
 
@@ -491,7 +499,7 @@ DirectoryOption::DirectoryOption (string const & i, string const & n, sigc::slot
 void
 DirectoryOption::set_state_from_config ()
 {
-       _file_chooser.set_current_folder (_get ());
+       _file_chooser.set_current_folder (poor_mans_glob(_get ()));
 }
 
 void
@@ -504,13 +512,13 @@ DirectoryOption::add_to_page (OptionEditorPage* p)
 }
 
 void
-DirectoryOption::file_set ()
+DirectoryOption::selection_changed ()
 {
-       _set (_file_chooser.get_filename ());
+       _set (poor_mans_glob(_file_chooser.get_filename ()));
 }
 
 void
 DirectoryOption::current_folder_set ()
 {
-       _set (_file_chooser.get_current_folder ());
+       _set (poor_mans_glob(_file_chooser.get_current_folder ()));
 }
index ac768383ee58438f8758e859b6c3ac6ecfc80122..9ab8132d2c116ea485a5c8bc0892553c0c6ccda2 100644 (file)
@@ -624,7 +624,7 @@ public:
         Gtk::Widget& tip_widget() { return _file_chooser; }
 
 private:
-       void file_set ();
+       void selection_changed ();
        void current_folder_set ();
        
        sigc::slot<std::string> _get; ///< slot to get the configuration variable's value