@ -84,7 +84,7 @@ pub fn connect_button_delete(gui_data: &GuiData) {
tree_remove ( scrolled_window_same_music_finder . clone ( ) , ColumnsSameMusic ::Name as i32 , ColumnsSameMusic ::Path as i32 , ColumnsSameMusic ::Color as i32 , & gui_data ) ;
}
"scrolled_window_invalid_symlinks" = > {
basic_remove _invalid_symlinks ( scrolled_window_invalid_symlinks . clone ( ) , ColumnsInvalidSymlinks :: SymlinkPath as i32 , & gui_data ) ;
basic_remove ( scrolled_window_invalid_symlinks . clone ( ) , ColumnsInvalidSymlinks ::Name as i32 , ColumnsInvalid Symlinks:: Path as i32 , & gui_data ) ;
}
e = > panic! ( "Not existent {}" , e ) ,
}
@ -177,38 +177,6 @@ fn empty_folder_remover(scrolled_window: gtk::ScrolledWindow, column_file_name:
selection . unselect_all ( ) ;
}
fn basic_remove_invalid_symlinks ( scrolled_window : gtk ::ScrolledWindow , column_symlink_path : i32 , gui_data : & GuiData ) {
let text_view_errors = gui_data . text_view_errors . clone ( ) ;
let tree_view = scrolled_window . get_children ( ) . get ( 0 ) . unwrap ( ) . clone ( ) . downcast ::< gtk ::TreeView > ( ) . unwrap ( ) ;
let selection = tree_view . get_selection ( ) ;
let ( selection_rows , tree_model ) = selection . get_selected_rows ( ) ;
if selection_rows . is_empty ( ) {
return ;
}
let list_store = tree_model . clone ( ) . downcast ::< gtk ::ListStore > ( ) . unwrap ( ) ;
// let new_tree_model = TreeModel::new(); // TODO - maybe create new model when inserting a new data, because this seems to be not optimal when using thousands of rows
let mut messages : String = "" . to_string ( ) ;
// Must be deleted from end to start, because when deleting entries, TreePath(and also TreeIter) will points to invalid data
for tree_path in selection_rows . iter ( ) . rev ( ) {
let symlink_path = tree_model . get_value ( & tree_model . get_iter ( tree_path ) . unwrap ( ) , column_symlink_path ) . get ::< String > ( ) . unwrap ( ) . unwrap ( ) ;
match fs ::remove_file ( & symlink_path ) {
Ok ( _ ) = > {
list_store . remove ( & list_store . get_iter ( tree_path ) . unwrap ( ) ) ;
}
Err ( _ ) = > messages + = format! ( "Failed to remove file {} because file doesn't exists or you don't have permissions.\n" , symlink_path ) . as_str ( ) ,
}
}
text_view_errors . get_buffer ( ) . unwrap ( ) . set_text ( messages . as_str ( ) ) ;
selection . unselect_all ( ) ;
}
fn basic_remove ( scrolled_window : gtk ::ScrolledWindow , column_file_name : i32 , column_path : i32 , gui_data : & GuiData ) {
let text_view_errors = gui_data . text_view_errors . clone ( ) ;