From 9d68192222ff1eb80f9fb91936948e32859c85e2 Mon Sep 17 00:00:00 2001 From: Taybin Rutkin Date: Wed, 10 Jan 2007 18:48:45 +0000 Subject: More polish. Don't try to import directories. git-svn-id: svn://localhost/ardour2/trunk@1299 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/sfdb_ui.cc | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index e2e0699640..a90f9289a8 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -21,6 +21,8 @@ #include #include +#include + #include #include @@ -390,17 +392,25 @@ SoundFileChooser::get_filename () Gtk::TreeModel::iterator iter; Gtk::TreeModel::Row row; + string filename; switch (notebook.get_current_page()) { case 0: - return chooser.get_filename(); + filename = chooser.get_filename(); case 1: iter = found_list_view.get_selection()->get_selected(); row = *iter; - return row[found_list_columns.pathname]; + filename = row[found_list_columns.pathname]; default: /* NOT REACHED */ return ""; } + + struct stat buf; + if (stat (filename.c_str(), &buf) || !S_ISREG(buf.st_mode)) { + return ""; + } + + return filename; } vector SoundFileOmega::mode_strings; @@ -446,22 +456,34 @@ SoundFileOmega::get_split () vector SoundFileOmega::get_paths () { + vector results; + int n = notebook.get_current_page (); if (n == 0) { - return chooser.get_filenames (); - } - - typedef Gtk::TreeView::Selection::ListHandle_Path ListPath; - - vector results; - ListPath rows = found_list_view.get_selection()->get_selected_rows (); - for (ListPath::iterator i = rows.begin() ; i != rows.end(); ++i) { - Gtk::TreeIter iter = found_list->get_iter(*i); - string str = (*iter)[found_list_columns.pathname]; - results.push_back (str); + vector filenames = chooser.get_filenames(); + vector::iterator i; + for (i = filenames.begin(); i != filenames.end(); ++i) { + struct stat buf; + if ((!stat((*i).c_str(), &buf)) && S_ISREG(buf.st_mode)) { + results.push_back (*i); + } + } + return results; + + } else { + + typedef Gtk::TreeView::Selection::ListHandle_Path ListPath; + + ListPath rows = found_list_view.get_selection()->get_selected_rows (); + for (ListPath::iterator i = rows.begin() ; i != rows.end(); ++i) { + Gtk::TreeIter iter = found_list->get_iter(*i); + string str = (*iter)[found_list_columns.pathname]; + + results.push_back (str); + } + return results; } - return results; } void -- cgit v1.2.3