fn populate_groups_at_start(
    nb_object: &NotebookObject,
    model: &TreeModel,
    shared_current_path: Rc<RefCell<Option<TreePath>>>,
    tree_path: TreePath,
    image_compare_left: &Image,
    image_compare_right: &Image,
    current_group: u32,
    group_number: u32,
    check_button_left_preview_text: &CheckButton,
    check_button_right_preview_text: &CheckButton,
    scrolled_window_compare_choose_images: &ScrolledWindow,
    label_group_info: &gtk4::Label,
    shared_image_cache: Rc<RefCell<Vec<(String, String, Image, Image, TreePath)>>>,
    shared_using_for_preview: Rc<RefCell<(Option<TreePath>, Option<TreePath>)>>,
    button_go_previous_compare_group: &gtk4::Button,
    button_go_next_compare_group: &gtk4::Button,
) {
    if current_group == 1 {
        button_go_previous_compare_group.set_sensitive(false);
    } else {
        button_go_previous_compare_group.set_sensitive(true);
    }
    if current_group == group_number {
        button_go_next_compare_group.set_sensitive(false);
    } else {
        button_go_next_compare_group.set_sensitive(true);
    }

    let all_vec = get_all_path(model, &tree_path, nb_object.column_header.unwrap(), nb_object.column_path, nb_object.column_name);
    *shared_current_path.borrow_mut() = Some(tree_path);

    let cache_all_images = generate_cache_for_results(all_vec);

    // This is safe, because cache have at least 2 results
    image_compare_left.set_paintable(cache_all_images[0].2.paintable().as_ref());
    image_compare_right.set_paintable(cache_all_images[1].2.paintable().as_ref());

    *shared_using_for_preview.borrow_mut() = (Some(cache_all_images[0].4.clone()), Some(cache_all_images[1].4.clone()));

    check_button_left_preview_text.set_label(Some(&format!("1. {}", get_max_file_name(&cache_all_images[0].0, 60))));
    check_button_right_preview_text.set_label(Some(&format!("2. {}", get_max_file_name(&cache_all_images[1].0, 60))));

    label_group_info.set_text(
        flg!(
            "compare_groups_number",
            generate_translation_hashmap(vec![
                ("current_group", current_group.to_string()),
                ("all_groups", group_number.to_string()),
                ("images_in_group", cache_all_images.len().to_string())
            ])
        )
        .as_str(),
    );

    populate_similar_scrolled_view(
        scrolled_window_compare_choose_images,
        &cache_all_images,
        image_compare_left,
        image_compare_right,
        shared_using_for_preview.clone(),
        shared_image_cache.clone(),
        check_button_left_preview_text,
        check_button_right_preview_text,
        model,
        nb_object.column_selection,
    );

    *shared_image_cache.borrow_mut() = cache_all_images.clone();

    let mut found = false;
    for i in get_all_children(&scrolled_window_compare_choose_images.child().unwrap().downcast::<gtk4::Viewport>().unwrap()) {
        if i.widget_name() == "all_box" {
            let gtk_box = i.downcast::<gtk4::Box>().unwrap();
            update_bottom_buttons(&gtk_box, shared_using_for_preview, shared_image_cache);
            found = true;
            break;
        }
    }
    assert!(found);

    let is_active = model.get::<bool>(&model.iter(&cache_all_images[0].4).unwrap(), nb_object.column_selection);
    check_button_left_preview_text.set_active(is_active);
    let is_active = model.get::<bool>(&model.iter(&cache_all_images[1].4).unwrap(), nb_object.column_selection);
    check_button_right_preview_text.set_active(is_active);
}
/// Populate all parameters for current group, it is used at start and when changing groups
Populate all parameters for current group, it is used at start and when changing groups
Populate all parameters for current group it is used at start and when changing groups
fn populate_groups_at_start(
    nb_object: &NotebookObject,
    model: &TreeModel,
    shared_current_path: Rc<RefCell<Option<TreePath>>>,
    tree_path: TreePath,
    image_compare_left: &Image,
    image_compare_right: &Image,
    current_group: u32,
    group_number: u32,
    check_button_left_preview_text: &CheckButton,
    check_button_right_preview_text: &CheckButton,
    scrolled_window_compare_choose_images: &ScrolledWindow,
    label_group_info: &gtk4::Label,
    shared_image_cache: Rc<RefCell<Vec<(String, String, Image, Image, TreePath)>>>,
    shared_using_for_preview: Rc<RefCell<(Option<TreePath>, Option<TreePath>)>>,
    button_go_previous_compare_group: &gtk4::Button,
    button_go_next_compare_group: &gtk4::Button,
) {
    if current_group == 1 {
        button_go_previous_compare_group.set_sensitive(false);
    } else {
        button_go_previous_compare_group.set_sensitive(true);
    }
    if current_group == group_number {
        button_go_next_compare_group.set_sensitive(false);
    } else {
        button_go_next_compare_group.set_sensitive(true);
    }
    let all_vec = get_all_path(model, &tree_path, nb_object.column_header.unwrap(), nb_object.column_path, nb_object.column_name);
    *shared_current_path.borrow_mut() = Some(tree_path);
    let cache_all_images = generate_cache_for_results(all_vec);
    // This is safe, because cache have at least 2 results
    image_compare_left.set_paintable(cache_all_images[0].2.paintable().as_ref());
    image_compare_right.set_paintable(cache_all_images[1].2.paintable().as_ref());
    *shared_using_for_preview.borrow_mut() = (Some(cache_all_images[0].4.clone()), Some(cache_all_images[1].4.clone()));
    check_button_left_preview_text.set_label(Some(&format!("1. {}", get_max_file_name(&cache_all_images[0].0, 60))));
    check_button_right_preview_text.set_label(Some(&format!("2. {}", get_max_file_name(&cache_all_images[1].0, 60))));
    label_group_info.set_text(
        flg!(
            "compare_groups_number",
            generate_translation_hashmap(vec![
                ("current_group", current_group.to_string()),
                ("all_groups", group_number.to_string()),
                ("images_in_group", cache_all_images.len().to_string())
            ])
        )
        .as_str(),
    );
    populate_similar_scrolled_view(
        scrolled_window_compare_choose_images,
        &cache_all_images,
        image_compare_left,
        image_compare_right,
        shared_using_for_preview.clone(),
        shared_image_cache.clone(),
        check_button_left_preview_text,
        check_button_right_preview_text,
        model,
        nb_object.column_selection,
    );
    *shared_image_cache.borrow_mut() = cache_all_images.clone();
    let mut found = false;
    for i in get_all_children(&scrolled_window_compare_choose_images.child().unwrap().downcast::<gtk4::Viewport>().unwrap()) {
        if i.widget_name() == "all_box" {
            let gtk_box = i.downcast::<gtk4::Box>().unwrap();
            update_bottom_buttons(&gtk_box, shared_using_for_preview, shared_image_cache);
            found = true;
            break;
        }
    }
    assert!(found);
    let is_active = model.get::<bool>(&model.iter(&cache_all_images[0].4).unwrap(), nb_object.column_selection);
    check_button_left_preview_text.set_active(is_active);
    let is_active = model.get::<bool>(&model.iter(&cache_all_images[1].4).unwrap(), nb_object.column_selection);
    check_button_right_preview_text.set_active(is_active);
}
fn populate_groups_at_start ( nb_object : & NotebookObject , model : & TreeModel , shared_current_path : Rc < RefCell < Option < TreePath > > > , tree_path : TreePath , image_compare_left : & Image , image_compare_right : & Image , current_group : u32 , group_number : u32 , check_button_left_preview_text : & CheckButton , check_button_right_preview_text : & CheckButton , scrolled_window_compare_choose_images : & ScrolledWindow , label_group_info : & gtk4 :: Label , shared_image_cache : Rc < RefCell < Vec < ( String , String , Image , Image , TreePath ) > > > , shared_using_for_preview : Rc < RefCell < ( Option < TreePath > , Option < TreePath > ) > > , button_go_previous_compare_group : & gtk4 :: Button , button_go_next_compare_group : & gtk4 :: Button , ) { if current_group == 1 { button_go_previous_compare_group . set_sensitive ( false ) ; } else { button_go_previous_compare_group . set_sensitive ( true ) ; } if current_group == group_number { button_go_next_compare_group . set_sensitive ( false ) ; } else { button_go_next_compare_group . set_sensitive ( true ) ; } let all_vec = get_all_path ( model , & tree_path , nb_object . column_header . unwrap ( ) , nb_object . column_path , nb_object . column_name ) ; * shared_current_path . borrow_mut ( ) = Some ( tree_path ) ; let cache_all_images = generate_cache_for_results ( all_vec ) ; // This is safe, because cache have at least 2 results image_compare_left . set_paintable ( cache_all_images [ 0 ] . 2 . paintable ( ) . as_ref ( ) ) ; image_compare_right . set_paintable ( cache_all_images [ 1 ] . 2 . paintable ( ) . as_ref ( ) ) ; * shared_using_for_preview . borrow_mut ( ) = ( Some ( cache_all_images [ 0 ] . 4 . clone ( ) ) , Some ( cache_all_images [ 1 ] . 4 . clone ( ) ) ) ; check_button_left_preview_text . set_label ( Some ( & format ! ( " " get_max_file_name ( cache_all_images [ 0 ] 0 60 ) ) ) ) ; check_button_right_preview_text . set_label ( Some ( & format ! ( " " get_max_file_name ( cache_all_images [ 1 ] 0 60 ) ) ) ) ; label_group_info . set_text ( flg ! ( " " generate_translation_hashmap ( vec [ ( " " current_group to_string ( ) ) ( " " group_number to_string ( ) ) ( " " cache_all_images len ( ) to_string ( ) ) ] ) ) . as_str ( ) , ) ; populate_similar_scrolled_view ( scrolled_window_compare_choose_images , & cache_all_images , image_compare_left , image_compare_right , shared_using_for_preview . clone ( ) , shared_image_cache . clone ( ) , check_button_left_preview_text , check_button_right_preview_text , model , nb_object . column_selection , ) ; * shared_image_cache . borrow_mut ( ) = cache_all_images . clone ( ) ; let mut found = false ; for i in get_all_children ( & scrolled_window_compare_choose_images . child ( ) . unwrap ( ) . downcast :: < gtk4 :: Viewport > ( ) . unwrap ( ) ) { if i . widget_name ( ) == " " { let gtk_box = i . downcast :: < gtk4 :: Box > ( ) . unwrap ( ) ; update_bottom_buttons ( & gtk_box , shared_using_for_preview , shared_image_cache ) ; found = true ; break ; } } assert ! ( found ) ; let is_active = model . get :: < bool > ( & model . iter ( & cache_all_images [ 0 ] . 4 ) . unwrap ( ) , nb_object . column_selection ) ; check_button_left_preview_text . set_active ( is_active ) ; let is_active = model . get :: < bool > ( & model . iter ( & cache_all_images [ 1 ] . 4 ) . unwrap ( ) , nb_object . column_selection ) ; check_button_right_preview_text . set_active ( is_active ) ; }
Populate all parameters for current group, it is used at start and when changing groups
Populate all parameters for current group it is used at start and when changing groups
nb_object
&NotebookObject
model
&TreeModel
shared_current_path
Rc<RefCell<Option<TreePath>>>
tree_path
TreePath
image_compare_left
&Image
image_compare_right
&Image
current_group
u32
group_number
u32
check_button_left_preview_text
&CheckButton
check_button_right_preview_text
&CheckButton
scrolled_window_compare_choose_images
&ScrolledWindow
label_group_info
&gtk4::Label
shared_image_cache
Rc<RefCell<Vec<(String, String, Image, Image, TreePath)>>>
shared_using_for_preview
Rc<RefCell<(Option<TreePath>, Option<TreePath>)>>
button_go_previous_compare_group
&gtk4::Button
button_go_next_compare_group
&gtk4::Button
nb_object
&NotebookObject
model
&TreeModel
shared_current_path
Rc<RefCell<Option<TreePath>>>
tree_path
TreePath
image_compare_left
&Image
image_compare_right
&Image
current_group
u32
group_number
u32
check_button_left_preview_text
&CheckButton
check_button_right_preview_text
&CheckButton
scrolled_window_compare_choose_images
&ScrolledWindow
label_group_info
&gtk4::Label
shared_image_cache
Rc<RefCell<Vec<(String, String, Image, Image, TreePath)>>>
shared_using_for_preview
Rc<RefCell<(Option<TreePath>, Option<TreePath>)>>
button_go_previous_compare_group
&gtk4::Button
button_go_next_compare_group
&gtk4::Button