@@ -378,14 +378,34 @@ pub fn get_notebook_enum_from_tree_view(tree_view: &TreeView) -> NotebookMainEnu
378
378
}
379
379
}
380
380
}
381
+ pub fn get_tree_view_name_from_notebook_enum ( notebook_enum : NotebookMainEnum ) -> & ' static str {
382
+ match notebook_enum {
383
+ NotebookMainEnum :: Duplicate => "tree_view_duplicate_finder" ,
384
+ NotebookMainEnum :: EmptyDirectories => "tree_view_empty_folder_finder" ,
385
+ NotebookMainEnum :: EmptyFiles => "tree_view_empty_files_finder" ,
386
+ NotebookMainEnum :: Temporary => "tree_view_temporary_files_finder" ,
387
+ NotebookMainEnum :: BigFiles => "tree_view_big_files_finder" ,
388
+ NotebookMainEnum :: SimilarImages => "tree_view_similar_images_finder" ,
389
+ NotebookMainEnum :: SimilarVideos => "tree_view_similar_videos_finder" ,
390
+ NotebookMainEnum :: SameMusic => "tree_view_same_music_finder" ,
391
+ NotebookMainEnum :: Symlinks => "tree_view_invalid_symlinks" ,
392
+ NotebookMainEnum :: BrokenFiles => "tree_view_broken_files" ,
393
+ NotebookMainEnum :: BadExtensions => "tree_view_bad_extensions" ,
394
+ }
395
+ }
381
396
382
397
pub fn get_notebook_upper_enum_from_tree_view ( tree_view : & TreeView ) -> NotebookUpperEnum {
383
398
match ( * tree_view) . widget_name ( ) . to_string ( ) . as_str ( ) {
384
399
"tree_view_upper_included_directories" => NotebookUpperEnum :: IncludedDirectories ,
385
400
"tree_view_upper_excluded_directories" => NotebookUpperEnum :: ExcludedDirectories ,
386
- e => {
387
- panic ! ( "{}" , e)
388
- }
401
+ e => panic ! ( "{}" , e) ,
402
+ }
403
+ }
404
+ pub fn get_tree_view_name_from_notebook_upper_enum ( notebook_upper_enum : NotebookUpperEnum ) -> & ' static str {
405
+ match notebook_upper_enum {
406
+ NotebookUpperEnum :: IncludedDirectories => "tree_view_upper_included_directories" ,
407
+ NotebookUpperEnum :: ExcludedDirectories => "tree_view_upper_excluded_directories" ,
408
+ _ => panic ! ( ) ,
389
409
}
390
410
}
391
411
@@ -789,15 +809,46 @@ pub fn scale_step_function(scale: &Scale, _scroll_type: ScrollType, value: f64)
789
809
#[ cfg( test) ]
790
810
mod test {
791
811
use glib:: types:: Type ;
812
+ use glib:: Value ;
792
813
use gtk4:: prelude:: * ;
793
- use gtk4:: Orientation ;
814
+ use gtk4:: { Orientation , TreeView } ;
794
815
use image:: DynamicImage ;
795
816
796
817
use crate :: help_functions:: {
797
818
change_dimension_to_krotka, check_if_list_store_column_have_all_same_values, check_if_value_is_in_list_store, get_all_boxes_from_widget, get_all_direct_children,
798
- get_max_file_name, get_pixbuf_from_dynamic_image,
819
+ get_max_file_name, get_pixbuf_from_dynamic_image, get_string_from_list_store ,
799
820
} ;
800
821
822
+ #[ gtk4:: test]
823
+ fn test_get_string_from_list_store ( ) {
824
+ let columns_types: & [ Type ] = & [ Type :: STRING ] ;
825
+ let list_store = gtk4:: ListStore :: new ( columns_types) ;
826
+ let tree_view = TreeView :: with_model ( & list_store) ;
827
+
828
+ let values_to_add: & [ ( u32 , & dyn ToValue ) ] = & [ ( 0 , & "test" ) , ( 0 , & "test2" ) , ( 0 , & "test3" ) ] ;
829
+ for i in values_to_add {
830
+ list_store. set ( & list_store. append ( ) , & [ * i] ) ;
831
+ }
832
+ assert_eq ! (
833
+ get_string_from_list_store( & tree_view, 0 , None ) ,
834
+ vec![ "test" . to_string( ) , "test2" . to_string( ) , "test3" . to_string( ) ]
835
+ ) ;
836
+
837
+ let columns_types: & [ Type ] = & [ Type :: BOOL , Type :: STRING ] ;
838
+ let list_store = gtk4:: ListStore :: new ( columns_types) ;
839
+ let tree_view = TreeView :: with_model ( & list_store) ;
840
+
841
+ let values_to_add: & [ & [ ( u32 , & dyn ToValue ) ] ] = & [
842
+ & [ ( 0 , & Into :: < Value > :: into ( true ) ) , ( 1 , & Into :: < Value > :: into ( "test" ) ) ] ,
843
+ & [ ( 0 , & Into :: < Value > :: into ( true ) ) , ( 1 , & Into :: < Value > :: into ( "test2" ) ) ] ,
844
+ & [ ( 0 , & Into :: < Value > :: into ( false ) ) , ( 1 , & Into :: < Value > :: into ( "test3" ) ) ] ,
845
+ ] ;
846
+ for i in values_to_add {
847
+ list_store. set ( & list_store. append ( ) , i) ;
848
+ }
849
+ assert_eq ! ( get_string_from_list_store( & tree_view, 1 , Some ( 0 ) ) , vec![ "test" . to_string( ) , "test2" . to_string( ) ] ) ;
850
+ }
851
+
801
852
#[ gtk4:: test]
802
853
fn test_check_if_list_store_column_have_all_same_values ( ) {
803
854
let columns_types: & [ Type ] = & [ Type :: BOOL ] ;
0 commit comments