Fix CC interpolation (i.e. output a maximum reslution stream of CC for a line segment).
[ardour.git] / gtk2_ardour / new_session_dialog.cc
index 820a614ecc793906ee62aeba98ae6befd3eb2688..4c128d4bf37366155806f88de9ee6285233dd5e2 100644 (file)
@@ -20,6 +20,8 @@
 #include "i18n.h"
 #include "new_session_dialog.h"
 
+#include <pbd/error.h>
+
 #include <ardour/recent_sessions.h>
 #include <ardour/session_state_utils.h>
 #include <ardour/template_utils.h>
 
 #include <gtkmm2ext/window_title.h>
 
+using namespace Gtk;
 using namespace Gtkmm2ext;
-using namespace ARDOUR;
 using namespace PBD;
+using namespace ARDOUR;
 
 #include "opts.h"
 #include "utils.h"
@@ -48,14 +51,14 @@ NewSessionDialog::NewSessionDialog()
        : ArdourDialog ("session control")
 {
        in_destructor = false;
-       session_name_label = Gtk::manage(new class Gtk::Label(_("Name :")));
-       m_name = Gtk::manage(new class Gtk::Entry());
+       session_name_label = new Gtk::Label(_("Name :"));
+       m_name = new Gtk::Entry();
        m_name->set_text(ARDOUR_COMMAND_LINE::session_name);
 
-       chan_count_label_1 = Gtk::manage(new class Gtk::Label(_("channels")));
-       chan_count_label_2 = Gtk::manage(new class Gtk::Label(_("channels")));
-       chan_count_label_3 = Gtk::manage(new class Gtk::Label(_("channels")));
-       chan_count_label_4 = Gtk::manage(new class Gtk::Label(_("channels")));
+       chan_count_label_1 = new Gtk::Label(_("channels"));
+       chan_count_label_2 = new Gtk::Label(_("channels"));
+       chan_count_label_3 = new Gtk::Label(_("channels"));
+       chan_count_label_4 = new Gtk::Label(_("channels"));
 
        chan_count_label_1->set_alignment(0,0.5);
        chan_count_label_1->set_padding(0,0);
@@ -73,64 +76,64 @@ NewSessionDialog::NewSessionDialog()
        chan_count_label_4->set_padding(0,0);
        chan_count_label_4->set_line_wrap(false);
 
-       bus_label = Gtk::manage(new class Gtk::Label(_("<b>Busses</b>")));
-       input_label = Gtk::manage(new class Gtk::Label(_("<b>Inputs</b>")));
-       output_label = Gtk::manage(new class Gtk::Label(_("<b>Outputs</b>")));
+       bus_label = new Gtk::Label(_("<b>Busses</b>"));
+       input_label = new Gtk::Label(_("<b>Inputs</b>"));
+       output_label = new Gtk::Label(_("<b>Outputs</b>"));
 
-       session_location_label = Gtk::manage(new class Gtk::Label(_("Create Folder In :")));
-       m_folder = Gtk::manage(new class Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
-       session_template_label = Gtk::manage(new class Gtk::Label(_("Template :")));
-       m_template = Gtk::manage(new class Gtk::FileChooserButton());
-       m_create_control_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Monitor Bus")));
+       session_location_label = new Gtk::Label(_("Create Folder In :"));
+       m_folder = new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
+       session_template_label = new Gtk::Label(_("Template :"));
+       m_template = new Gtk::FileChooserButton();
+       m_create_control_bus = new Gtk::CheckButton(_("Create Monitor Bus"));
+       
+       Gtk::Adjustment *m_control_bus_channel_count_adj = Gtk::manage(new Gtk::Adjustment(2, 0, 100, 1, 10, 10));
+       m_control_bus_channel_count = new Gtk::SpinButton(*m_control_bus_channel_count_adj, 1, 0);
        
-       Gtk::Adjustment *m_control_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
-       m_control_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_control_bus_channel_count_adj, 1, 0));
+       Gtk::Adjustment *m_master_bus_channel_count_adj = Gtk::manage(new Gtk::Adjustment(2, 0, 100, 1, 10, 10));
+       m_master_bus_channel_count = new Gtk::SpinButton(*m_master_bus_channel_count_adj, 1, 0);
+       m_create_master_bus = new Gtk::CheckButton(_("Create Master Bus"));
+       advanced_table = new Gtk::Table(2, 2, true);
+       m_connect_inputs = new Gtk::CheckButton(_("Automatically Connect to Physical Inputs"));
+       m_limit_input_ports = new Gtk::CheckButton(_("Use only"));
        
-       Gtk::Adjustment *m_master_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
-       m_master_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_master_bus_channel_count_adj, 1, 0));
-       m_create_master_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Master Bus")));
-       advanced_table = Gtk::manage(new class Gtk::Table(2, 2, true));
-       m_connect_inputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect to Physical Inputs")));
-       m_limit_input_ports = Gtk::manage(new class Gtk::CheckButton(_("Use only")));
+       Gtk::Adjustment *m_input_limit_count_adj = Gtk::manage(new Gtk::Adjustment(1, 0, 100, 1, 10, 10));
+       m_input_limit_count = new Gtk::SpinButton(*m_input_limit_count_adj, 1, 0);
+       input_port_limit_hbox = new Gtk::HBox(false, 0);
+       input_port_vbox = new Gtk::VBox(false, 0);
+       input_table = new Gtk::Table(2, 2, false);
+
+       bus_frame = new Gtk::Frame();
+       bus_table = new Gtk::Table (2, 3, false);
        
-       Gtk::Adjustment *m_input_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
-       m_input_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_input_limit_count_adj, 1, 0));
-       input_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
-       input_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
-       input_table = Gtk::manage(new class Gtk::Table(2, 2, false));
-
-       bus_frame = Gtk::manage(new class Gtk::Frame());
-       bus_table = Gtk::manage (new Gtk::Table (2, 3, false));
-
-       input_frame = Gtk::manage(new class Gtk::Frame());
-       m_connect_outputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect Outputs")));
-       m_limit_output_ports = Gtk::manage(new class Gtk::CheckButton(_("Use only")));
+       input_frame = new Gtk::Frame();
+       m_connect_outputs = new Gtk::CheckButton(_("Automatically Connect Outputs"));
+       m_limit_output_ports = new Gtk::CheckButton(_("Use only"));
        
-       Gtk::Adjustment *m_output_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
-       m_output_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_output_limit_count_adj, 1, 0));
-       output_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
-       output_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
+       Gtk::Adjustment *m_output_limit_count_adj = Gtk::manage(new Gtk::Adjustment(1, 0, 100, 1, 10, 10));
+       m_output_limit_count = new Gtk::SpinButton(*m_output_limit_count_adj, 1, 0);
+       output_port_limit_hbox = new Gtk::HBox(false, 0);
+       output_port_vbox = new Gtk::VBox(false, 0);
        
        Gtk::RadioButton::Group _RadioBGroup_m_connect_outputs_to_master;
-       m_connect_outputs_to_master = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Master Bus")));
-       m_connect_outputs_to_physical = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Physical Outputs")));
-       output_conn_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
-       output_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
-
-       output_frame = Gtk::manage(new class Gtk::Frame());
-       advanced_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
-       advanced_label = Gtk::manage(new class Gtk::Label(_("Advanced Options")));
-       advanced_expander = Gtk::manage(new class Gtk::Expander());
-       new_session_table = Gtk::manage(new class Gtk::Table(2, 2, false));
-       m_open_filechooser = Gtk::manage(new class Gtk::FileChooserButton());
-       open_session_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
-       m_treeview = Gtk::manage(new class Gtk::TreeView());
-       recent_scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow());
-
-       recent_sesion_label = Gtk::manage(new class Gtk::Label(_("Recent:")));
-       recent_frame = Gtk::manage(new class Gtk::Frame());
-       open_session_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
-       m_notebook = Gtk::manage(new class Gtk::Notebook());
+       m_connect_outputs_to_master = new Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Master Bus"));
+       m_connect_outputs_to_physical = new Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Physical Outputs"));
+       output_conn_vbox = new Gtk::VBox(false, 0);
+       output_vbox = new Gtk::VBox(false, 0);
+
+       output_frame = new Gtk::Frame();
+       advanced_vbox = new Gtk::VBox(false, 0);
+       advanced_label = new Gtk::Label(_("Advanced Options"));
+       advanced_expander = new Gtk::Expander();
+       new_session_table = new Gtk::Table(2, 2, false);
+       m_open_filechooser = new Gtk::FileChooserButton();
+       open_session_hbox = new Gtk::HBox(false, 0);
+       m_treeview = new Gtk::TreeView();
+       recent_scrolledwindow = new Gtk::ScrolledWindow();
+
+       recent_sesion_label = new Gtk::Label(_("Recent:"));
+       recent_frame = new Gtk::Frame();
+       open_session_vbox = new Gtk::VBox(false, 0);
+       m_notebook = new Gtk::Notebook();
        session_name_label->set_alignment(0, 0.5);
        session_name_label->set_padding(6,0);
        session_name_label->set_line_wrap(false);
@@ -164,7 +167,7 @@ NewSessionDialog::NewSessionDialog()
        m_master_bus_channel_count->set_numeric(true);
        m_master_bus_channel_count->set_digits(0);
        m_master_bus_channel_count->set_wrap(false);
-       open_session_file_label = Gtk::manage(new class Gtk::Label(_("Browse:")));
+       open_session_file_label = new Gtk::Label(_("Browse:"));
        open_session_file_label->set_alignment(0, 0.5);
        m_create_master_bus->set_flags(Gtk::CAN_FOCUS);
        m_create_master_bus->set_relief(Gtk::RELIEF_NORMAL);
@@ -173,7 +176,7 @@ NewSessionDialog::NewSessionDialog()
        m_create_master_bus->set_border_width(0);
        advanced_table->set_row_spacings(0);
        advanced_table->set_col_spacings(0);
-
+       
        m_connect_inputs->set_flags(Gtk::CAN_FOCUS);
        m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL);
        m_connect_inputs->set_mode(true);
@@ -192,7 +195,7 @@ NewSessionDialog::NewSessionDialog()
        m_input_limit_count->set_wrap(false);
        m_input_limit_count->set_sensitive(false);
 
-       bus_hbox = Gtk::manage (new Gtk::HBox (false, 0));
+       bus_hbox = new Gtk::HBox (false, 0);
        bus_hbox->pack_start (*bus_table, Gtk::PACK_SHRINK, 18);
 
        bus_label->set_alignment(0, 0.5);
@@ -223,7 +226,7 @@ NewSessionDialog::NewSessionDialog()
        input_table->set_col_spacings(0);
        input_table->attach(*input_port_vbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 6);
 
-       input_hbox = Gtk::manage (new Gtk::HBox (false, 0));
+       input_hbox = new Gtk::HBox (false, 0);
        input_hbox->pack_start (*input_table, Gtk::PACK_SHRINK, 18);
 
        input_label->set_alignment(0, 0.5);
@@ -283,7 +286,7 @@ NewSessionDialog::NewSessionDialog()
        output_frame->set_shadow_type(Gtk::SHADOW_NONE);
        output_frame->set_label_align(0,0.5);
 
-       output_hbox = Gtk::manage (new Gtk::HBox (false, 0));
+       output_hbox = new Gtk::HBox (false, 0);
        output_hbox->pack_start (*output_vbox, Gtk::PACK_SHRINK, 18);
 
        output_frame->add(*output_hbox);
@@ -377,12 +380,9 @@ NewSessionDialog::NewSessionDialog()
        title += _("Session Control");
        set_title(title.get_string());
 
-       //set_modal(false);
-       //property_window_position().set_value(Gtk::WIN_POS_NONE);
+       set_position (Gtk::WIN_POS_MOUSE);
        set_resizable(false);
-       //property_destroy_with_parent().set_value(false);
        set_has_separator(false);
-       // add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
        add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CANCEL);
        add_button(Gtk::Stock::CLEAR, Gtk::RESPONSE_NONE);
        m_okbutton = add_button(Gtk::Stock::NEW, Gtk::RESPONSE_OK);
@@ -526,7 +526,49 @@ NewSessionDialog::set_session_name (const Glib::ustring& name)
 void
 NewSessionDialog::set_session_folder(const Glib::ustring& dir)
 {
-       m_folder->set_current_folder (dir);
+       Glib::ustring realdir = dir;
+       char* res;
+
+       /* this little tangled mess is a result of 4 things:
+
+           1) GtkFileChooser vomits when given a non-absolute directory
+                   argument to set_current_folder()
+            2) canonicalize_file_name() doesn't exist on OS X
+           3) linux man page for realpath() says "do not use this function"
+           4) canonicalize_file_name() & realpath() have entirely
+                   different semantics on OS X and Linux when given
+                  a non-existent path.
+                  
+          as result of all this, we take two distinct pathways through the code.
+       */
+
+
+#ifdef __APPLE__
+
+       char buf[PATH_MAX];
+
+       if((res = realpath (dir.c_str(), buf)) != 0) {
+               if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
+                       realdir = Glib::path_get_dirname (realdir);
+               }
+               m_folder->set_current_folder (realdir);
+       }
+
+       
+#else 
+       if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
+               realdir = Glib::path_get_dirname (realdir);
+               cerr << "didn't exist, use " << realdir << endl;
+       }
+
+       if ((res = canonicalize_file_name (realdir.c_str())) != 0) {
+               cerr << "canonical, use " << res << endl;
+               m_folder->set_current_folder (res);
+               free (res);
+       }
+       
+#endif
+
 }
 
 std::string
@@ -547,40 +589,54 @@ NewSessionDialog::session_name() const
        }         
        */
 
-       int page = m_notebook->get_current_page();
-
-       if (page == 0 || page == 2) {
+       switch (which_page()) {
+       case NewPage:
+       case EnginePage:
                /* new or audio setup pages */
                return Glib::filename_from_utf8(m_name->get_text());
-       } else {
-               if (m_treeview->get_selection()->count_selected_rows() == 0) {
-                       return Glib::filename_from_utf8(str);
-               }
-               Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
-               return (*i)[recent_columns.visible_name];
+       default:
+               break;
+       } 
+
+       if (m_treeview->get_selection()->count_selected_rows() == 0) {
+               return Glib::filename_from_utf8(str);
        }
+       Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
+       return (*i)[recent_columns.visible_name];
 }
 
 std::string
 NewSessionDialog::session_folder() const
 {
-       if (m_notebook->get_current_page() == 0) {
+       switch (which_page()) {
+       case NewPage:
                return Glib::filename_from_utf8(m_folder->get_filename());
-       } else {
-              
-               if (m_treeview->get_selection()->count_selected_rows() == 0) {
-                       const string filename(Glib::filename_from_utf8(m_open_filechooser->get_filename()));
-                       return Glib::path_get_dirname(filename);
+               
+       case EnginePage:
+               if (page_set == EnginePage) {
+                       /* just engine page, nothing else : use m_folder since it should be set */
+                       return Glib::filename_from_utf8(m_folder->get_filename());
                }
-               Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
-               return (*i)[recent_columns.fullpath];
+               break;
+
+       default:
+               break;
        }
+              
+       if (m_treeview->get_selection()->count_selected_rows() == 0) {
+               const string filename(Glib::filename_from_utf8(m_open_filechooser->get_filename()));
+               return Glib::path_get_dirname(filename);
+       }
+
+       Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
+       return (*i)[recent_columns.fullpath];
 }
 
 bool
 NewSessionDialog::use_session_template() const
 {
-       if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
+       if (m_template->get_filename().empty() && (which_page() == NewPage))
+               return false;
        return true;
 }
 
@@ -663,13 +719,13 @@ NewSessionDialog::connect_outs_to_physical() const
 }
 
 int
-NewSessionDialog::get_current_page() const
+NewSessionDialog::get_current_page()
 {
        return m_notebook->get_current_page();
 }
 
 NewSessionDialog::Pages
-NewSessionDialog::which_page ()
+NewSessionDialog::which_page () const
 {
        int num = m_notebook->get_current_page();
 
@@ -682,7 +738,7 @@ NewSessionDialog::which_page ()
        } else if (page_set == EnginePage) {
                return EnginePage;
 
-       } else if (page_set == NewPage|OpenPage) {
+       } else if (page_set == (NewPage|OpenPage)) {
                switch (num) {
                case 0:
                        return NewPage;
@@ -690,7 +746,7 @@ NewSessionDialog::which_page ()
                        return OpenPage;
                }
 
-       } else if (page_set == NewPage|EnginePage) {
+       } else if (page_set == (NewPage|EnginePage)) {
                switch (num) {
                case 0:
                        return NewPage;
@@ -698,7 +754,7 @@ NewSessionDialog::which_page ()
                        return EnginePage;
                }
 
-       } else if (page_set == NewPage|EnginePage|OpenPage) {
+       } else if (page_set == (NewPage|EnginePage|OpenPage)) {
                switch (num) {
                case 0:
                        return NewPage;
@@ -708,7 +764,7 @@ NewSessionDialog::which_page ()
                        return EnginePage;
                }
 
-       } else if (page_set == OpenPage|EnginePage) {
+       } else if (page_set == (OpenPage|EnginePage)) {
                switch (num) {
                case 0:
                        return OpenPage;
@@ -716,6 +772,8 @@ NewSessionDialog::which_page ()
                        return EnginePage;
                }
        }
+
+       return NewPage; /* shouldn't get here */
 }
 
 void
@@ -755,7 +813,6 @@ NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
                m_okbutton->set_label(_("Open"));
                m_okbutton->set_image (*(manage (new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON))));
                set_response_sensitive (Gtk::RESPONSE_NONE, false);
-               m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
                if (m_treeview->get_selection()->count_selected_rows() == 0) {
                        set_response_sensitive (Gtk::RESPONSE_OK, false);
                } else {
@@ -772,8 +829,7 @@ NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
                break;
 
        default:
-               m_okbutton->set_label(_("New"));
-               m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
+               on_new_session_page = true;
                m_okbutton->set_label(_("New"));
                m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
                if (m_name->get_text() == "") {
@@ -839,7 +895,7 @@ NewSessionDialog::template_chosen ()
 void
 NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
 {
-       response (Gtk::RESPONSE_YES);
+       response (Gtk::RESPONSE_OK);
 }
 
 void
@@ -893,13 +949,15 @@ NewSessionDialog::monitor_bus_button_clicked ()
 void
 NewSessionDialog::reset_template()
 {
-       m_template->set_filename("");
+       m_template->unselect_all ();
 }
 
 void
 NewSessionDialog::reset_recent()
 {
-       std::vector<sys::path> session_directories;
+       /* Shamelessly ripped from ardour_ui.cc */
+       std::vector<string *> *sessions;
+       std::vector<string *>::iterator i;
        RecentSessionsSorter cmp;
        
        recent_model->clear ();
@@ -907,51 +965,62 @@ NewSessionDialog::reset_recent()
        ARDOUR::RecentSessions rs;
        ARDOUR::read_recent_sessions (rs);
        
-       // sort them alphabetically
+       /* sort them alphabetically */
        sort (rs.begin(), rs.end(), cmp);
+       sessions = new std::vector<std::string*>;
        
        for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
-               session_directories.push_back ((*i).second);
+               sessions->push_back (new string ((*i).second));
        }
        
-       for (vector<sys::path>::const_iterator i = session_directories.begin();
-                       i != session_directories.end(); ++i)
-       {
-               std::vector<sys::path> state_file_paths;
-           
-               // now get available states for this session
-
-               get_state_files_in_directory (*i, state_file_paths);
+       for (i = sessions->begin(); i != sessions->end(); ++i) {
 
-               if (state_file_paths.empty()) {
-                       // no state file?
+               std::vector<std::string*>* states;
+               std::vector<const gchar*> item;
+               std::string fullpath = *(*i);
+               
+               /* remove any trailing / */
+               
+               if (fullpath[fullpath.length()-1] == '/') {
+                       fullpath = fullpath.substr (0, fullpath.length()-1);
+               }
+           
+               /* check whether session still exists */
+               if (!Glib::file_test(fullpath, Glib::FILE_TEST_EXISTS)) {
+                       /* session doesn't exist */
                        continue;
+               }               
+               
+               /* now get available states for this session */
+                 
+               if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
+                       /* no state file? */
+                       continue;
                }
-         
-               std::vector<string> state_file_names(get_file_names_no_extension (state_file_paths));
-
+           
                Gtk::TreeModel::Row row = *(recent_model->append());
-
-               const string fullpath = (*i).to_string();
                
                row[recent_columns.visible_name] = Glib::path_get_basename (fullpath);
                row[recent_columns.fullpath] = fullpath;
                
-               if (state_file_names.size() > 1) {
-
-                       // add the children
-
-                       for (std::vector<std::string>::iterator i2 = state_file_names.begin();
-                                       i2 != state_file_names.end(); ++i2)
-                       {
-
-                               Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
-
-                               child_row[recent_columns.visible_name] = *i2;
+               if (states->size()) {
+                   
+                       /* add the children */
+                   
+                       for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
+
+                               Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
+                               
+                               child_row[recent_columns.visible_name] = **i2;
                                child_row[recent_columns.fullpath] = fullpath;
+                               
+                               delete *i2;
                        }
                }
+
+               delete states;
        }
+       delete sessions;
 }
 
 void