+
+/** Add a new page
+ * @param pn Page name (will be created if it doesn't already exist)
+ * @param w widget that fills the page
+ */
+void
+OptionEditor::add_page (std::string const & pn, Gtk::Widget& w)
+{
+ if (_pages.find (pn) == _pages.end()) {
+ _pages[pn] = new OptionEditorPage (_notebook, pn);
+ }
+
+ OptionEditorPage* p = _pages[pn];
+ p->box.pack_start (w, true, true);
+}
+
+void
+OptionEditor::set_current_page (string const & p)
+{
+ int i = 0;
+ while (i < _notebook.get_n_pages ()) {
+ if (_notebook.get_tab_label_text (*_notebook.get_nth_page (i)) == p) {
+ _notebook.set_current_page (i);
+ return;
+ }
+
+ ++i;
+ }
+}
+
+
+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_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));
+}
+
+
+void
+DirectoryOption::set_state_from_config ()
+{
+ _file_chooser.set_current_folder (poor_mans_glob(_get ()));
+}
+
+void
+DirectoryOption::add_to_page (OptionEditorPage* p)
+{
+ Gtk::Label *label = manage (new Label (_name));
+ label->set_alignment (0, 0.5);
+ label->set_name (X_("OptionsLabel"));
+ add_widgets_to_page (p, label, &_file_chooser);
+}
+
+void
+DirectoryOption::selection_changed ()
+{
+ _set (poor_mans_glob(_file_chooser.get_filename ()));
+}
+
+void
+DirectoryOption::current_folder_set ()
+{
+ _set (poor_mans_glob(_file_chooser.get_current_folder ()));
+}