13
0

path-dialogue: check for and disallow duplicates

This commit is contained in:
Robin Gareus 2014-02-28 17:32:57 +01:00
parent bf47f57ee7
commit a5d7bf0f24

View File

@ -116,8 +116,17 @@ PathsDialog::add_path() {
if (r == Gtk::RESPONSE_OK) {
std::string dir = d.get_filename();
if (Glib::file_test (dir, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
paths_list_view.prepend(_("user"));
paths_list_view.set_text(0, 1, dir);
bool dup = false;
for (unsigned int i = 0; i < paths_list_view.size(); ++i) {
if (paths_list_view.get_text(i, 1) == dir) {
dup = true;
break;
}
}
if (!dup) {
paths_list_view.prepend(_("user"));
paths_list_view.set_text(0, 1, dir);
}
}
}
}