+void
+OptionEditor::treeview_row_selected ()
+{
+ Glib::RefPtr<Gtk::TreeSelection> selection = option_treeview.get_selection();
+ TreeModel::iterator iter = selection->get_selected();
+ if(iter) {
+ TreeModel::Row row = *iter;
+ Gtk::Widget* w = row[option_columns.widget];
+ if (w) {
+ _notebook.set_current_page (_notebook.page_num (*w));
+ }
+ }
+}
+
+TreeModel::iterator
+OptionEditor::find_path_in_treemodel (std::string const & pn, bool create_missing)
+{
+ /* split page name, which is actually a path, into each component */
+
+ std::vector<std::string> components;
+ split (pn, components, '/');
+
+ /* start with top level children */
+
+ TreeModel::Children children = option_tree->children();
+ TreeModel::iterator iter;
+
+ /* foreach path component ... */
+
+ for (std::vector<std::string>::const_iterator s = components.begin(); s != components.end(); ++s) {
+
+ for (iter = children.begin(); iter != children.end(); ++iter) {
+ TreeModel::Row row = *iter;
+ const std::string row_name = row[option_columns.name];
+ if (row_name == (*s)) {
+ break;
+ }
+ }
+
+ if (iter == children.end()) {
+ /* the current component is missing; bail out or create it */
+ if (!create_missing) {
+ return option_tree->get_iter(TreeModel::Path(""));
+ } else {
+ iter = option_tree->append (children);
+ TreeModel::Row row = *iter;
+ row[option_columns.name] = *s;
+ row[option_columns.widget] = 0;
+ }
+ }
+
+ /* from now on, iter points to a valid row, either the one we found or a new one */
+ /* set children to the row's children to continue searching */
+ children = (*iter)->children ();
+
+ }
+
+ return iter;
+}
+
+void
+OptionEditor::add_path_to_treeview (std::string const & pn, Gtk::Widget& widget)
+{
+ option_treeview.set_model (Glib::RefPtr<TreeStore>());
+
+ TreeModel::iterator row_iter = find_path_in_treemodel(pn, true);
+
+ assert(row_iter);
+
+ TreeModel::Row row = *row_iter;
+ row[option_columns.widget] = &widget;
+
+ option_treeview.set_model (option_tree);
+ option_treeview.expand_all ();
+}
+