From 9197edcf16e47558afbf6000c693fcb8fba97cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= <41945903+qarmin@users.noreply.github.com> Date: Sun, 16 Jan 2022 17:54:44 +0100 Subject: [PATCH] Remove GTK warning (#587) --- .../connect_things/connect_button_compare.rs | 67 ++++++++++--------- .../connect_things/connect_button_hardlink.rs | 2 - .../src/gui_structs/gui_compare_images.rs | 8 +-- czkawka_gui/ui/about_dialog.glade | 2 +- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/czkawka_gui/src/connect_things/connect_button_compare.rs b/czkawka_gui/src/connect_things/connect_button_compare.rs index 4d46eb3..0fc31e7 100644 --- a/czkawka_gui/src/connect_things/connect_button_compare.rs +++ b/czkawka_gui/src/connect_things/connect_button_compare.rs @@ -35,7 +35,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { let shared_numbers_of_groups = gui_data.compare_images.shared_numbers_of_groups.clone(); let shared_current_of_groups = gui_data.compare_images.shared_current_of_groups.clone(); - let shared_current_iter = gui_data.compare_images.shared_current_iter.clone(); + let shared_current_path = gui_data.compare_images.shared_current_path.clone(); let shared_image_cache = gui_data.compare_images.shared_image_cache.clone(); let shared_using_for_preview = gui_data.compare_images.shared_using_for_preview.clone(); @@ -55,7 +55,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { } // Check selected items - let (current_group, tree_iter) = get_current_group_and_iter_from_selection(&model, tree_view.selection(), nb_object.column_color.unwrap()); + let (current_group, tree_path) = get_current_group_and_iter_from_selection(&model, tree_view.selection(), nb_object.column_color.unwrap()); *shared_current_of_groups.borrow_mut() = current_group; *shared_numbers_of_groups.borrow_mut() = group_number; @@ -63,8 +63,8 @@ pub fn connect_button_compare(gui_data: &GuiData) { populate_groups_at_start( nb_object, &model, - shared_current_iter.clone(), - tree_iter, + shared_current_path.clone(), + tree_path, &image_compare_left, &image_compare_right, current_group, @@ -83,7 +83,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { }); let shared_image_cache = gui_data.compare_images.shared_image_cache.clone(); - let shared_current_iter = gui_data.compare_images.shared_current_iter.clone(); + let shared_current_path = gui_data.compare_images.shared_current_path.clone(); let shared_using_for_preview = gui_data.compare_images.shared_using_for_preview.clone(); let shared_current_of_groups = gui_data.compare_images.shared_current_of_groups.clone(); let shared_numbers_of_groups = gui_data.compare_images.shared_numbers_of_groups.clone(); @@ -93,7 +93,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { window_compare.connect_delete_event(move |window_compare, _| { window_compare.hide(); *shared_image_cache.borrow_mut() = Vec::new(); - *shared_current_iter.borrow_mut() = None; + *shared_current_path.borrow_mut() = None; *shared_current_of_groups.borrow_mut() = 0; *shared_numbers_of_groups.borrow_mut() = 0; *shared_using_for_preview.borrow_mut() = (None, None); @@ -114,7 +114,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { let shared_current_of_groups = gui_data.compare_images.shared_current_of_groups.clone(); let shared_numbers_of_groups = gui_data.compare_images.shared_numbers_of_groups.clone(); - let shared_current_iter = gui_data.compare_images.shared_current_iter.clone(); + let shared_current_path = gui_data.compare_images.shared_current_path.clone(); let shared_image_cache = gui_data.compare_images.shared_image_cache.clone(); let shared_using_for_preview = gui_data.compare_images.shared_using_for_preview.clone(); @@ -132,12 +132,12 @@ pub fn connect_button_compare(gui_data: &GuiData) { let current_group = *shared_current_of_groups.borrow(); let group_number = *shared_numbers_of_groups.borrow(); - let tree_iter = move_iter(&model, shared_current_iter.borrow().as_ref().unwrap(), nb_object.column_color.unwrap(), false); + let tree_iter = move_iter(&model, shared_current_path.borrow().as_ref().unwrap(), nb_object.column_color.unwrap(), false); populate_groups_at_start( nb_object, &model, - shared_current_iter.clone(), + shared_current_path.clone(), tree_iter, &image_compare_left, &image_compare_right, @@ -166,7 +166,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { let shared_current_of_groups = gui_data.compare_images.shared_current_of_groups.clone(); let shared_numbers_of_groups = gui_data.compare_images.shared_numbers_of_groups.clone(); - let shared_current_iter = gui_data.compare_images.shared_current_iter.clone(); + let shared_current_path = gui_data.compare_images.shared_current_path.clone(); let shared_image_cache = gui_data.compare_images.shared_image_cache.clone(); let shared_using_for_preview = gui_data.compare_images.shared_using_for_preview.clone(); @@ -184,13 +184,13 @@ pub fn connect_button_compare(gui_data: &GuiData) { let current_group = *shared_current_of_groups.borrow(); let group_number = *shared_numbers_of_groups.borrow(); - let tree_iter = move_iter(&model, shared_current_iter.borrow().as_ref().unwrap(), nb_object.column_color.unwrap(), true); + let tree_path = move_iter(&model, shared_current_path.borrow().as_ref().unwrap(), nb_object.column_color.unwrap(), true); populate_groups_at_start( nb_object, &model, - shared_current_iter.clone(), - tree_iter, + shared_current_path.clone(), + tree_path, &image_compare_left, &image_compare_right, current_group, @@ -209,7 +209,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { let check_button_left_preview_text = gui_data.compare_images.check_button_left_preview_text.clone(); let shared_using_for_preview = gui_data.compare_images.shared_using_for_preview.clone(); let notebook_main = gui_data.main_notebook.notebook_main.clone(); - let shared_current_iter = gui_data.compare_images.shared_current_iter.clone(); + let shared_current_path = gui_data.compare_images.shared_current_path.clone(); let main_tree_views = gui_data.main_notebook.get_main_tree_views(); check_button_left_preview_text.connect_clicked(move |check_button_left_preview_text| { let nb_number = notebook_main.current_page().unwrap(); @@ -217,7 +217,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { let nb_object = &NOTEBOOKS_INFOS[nb_number as usize]; let model = tree_view.model().unwrap().downcast::().unwrap(); - let main_tree_path = model.path(shared_current_iter.borrow().as_ref().unwrap()).unwrap(); + let main_tree_path = shared_current_path.borrow().as_ref().unwrap().clone(); let this_tree_path = shared_using_for_preview.borrow().0.clone().unwrap(); if main_tree_path == this_tree_path { return; // Selected header, so we don't need to select result in treeview @@ -230,7 +230,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { let check_button_right_preview_text = gui_data.compare_images.check_button_right_preview_text.clone(); let shared_using_for_preview = gui_data.compare_images.shared_using_for_preview.clone(); - let shared_current_iter = gui_data.compare_images.shared_current_iter.clone(); + let shared_current_path = gui_data.compare_images.shared_current_path.clone(); let notebook_main = gui_data.main_notebook.notebook_main.clone(); let main_tree_views = gui_data.main_notebook.get_main_tree_views(); check_button_right_preview_text.connect_clicked(move |check_button_right_preview_text| { @@ -239,7 +239,7 @@ pub fn connect_button_compare(gui_data: &GuiData) { let nb_object = &NOTEBOOKS_INFOS[nb_number as usize]; let model = tree_view.model().unwrap().downcast::().unwrap(); - let main_tree_path = model.path(shared_current_iter.borrow().as_ref().unwrap()).unwrap(); + let main_tree_path = shared_current_path.borrow().as_ref().unwrap().clone(); let this_tree_path = shared_using_for_preview.borrow().1.clone().unwrap(); if main_tree_path == this_tree_path { return; // Selected header, so we don't need to select result in treeview @@ -255,8 +255,8 @@ pub fn connect_button_compare(gui_data: &GuiData) { fn populate_groups_at_start( nb_object: &NotebookObject, model: &TreeModel, - shared_current_iter: Rc>>, - tree_iter: TreeIter, + shared_current_path: Rc>>, + tree_path: TreePath, image_compare_left: >k::Image, image_compare_right: >k::Image, current_group: u32, @@ -281,8 +281,8 @@ fn populate_groups_at_start( button_go_next_compare_group.set_sensitive(true); } - let all_vec = get_all_path(model, &tree_iter, nb_object.column_color.unwrap(), nb_object.column_path, nb_object.column_name); - *shared_current_iter.borrow_mut() = Some(tree_iter); + let all_vec = get_all_path(model, &tree_path, nb_object.column_color.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); @@ -382,8 +382,8 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, gtk::TreePa } /// Takes info about current items in groups like path -fn get_all_path(model: &TreeModel, current_iter: &TreeIter, column_color: i32, column_path: i32, column_name: i32) -> Vec<(String, String, gtk::TreePath)> { - let used_iter = current_iter.clone(); +fn get_all_path(model: &TreeModel, current_path: &TreePath, column_color: i32, column_path: i32, column_name: i32) -> Vec<(String, String, gtk::TreePath)> { + let used_iter = model.iter(current_path).unwrap(); assert_eq!(model.value(&used_iter, column_color).get::().unwrap(), HEADER_ROW_COLOR); let using_reference = !model.value(&used_iter, column_path).get::().unwrap().is_empty(); @@ -428,37 +428,38 @@ fn get_all_path(model: &TreeModel, current_iter: &TreeIter, column_color: i32, c } /// Moves iterator to previous/next header -fn move_iter(model: >k::TreeModel, tree_iter: &TreeIter, column_color: i32, go_next: bool) -> TreeIter { - assert_eq!(model.value(tree_iter, column_color).get::().unwrap(), HEADER_ROW_COLOR); +fn move_iter(model: >k::TreeModel, tree_path: &TreePath, column_color: i32, go_next: bool) -> TreePath { + let tree_iter = model.iter(tree_path).unwrap(); + assert_eq!(model.value(&tree_iter, column_color).get::().unwrap(), HEADER_ROW_COLOR); if go_next { - if !model.iter_next(tree_iter) { + if !model.iter_next(&tree_iter) { panic!("Found only header!"); } } else { - if !model.iter_previous(tree_iter) { + if !model.iter_previous(&tree_iter) { panic!("Found only header!"); } } loop { if go_next { - if !model.iter_next(tree_iter) { + if !model.iter_next(&tree_iter) { break; } } else { - if !model.iter_previous(tree_iter) { + if !model.iter_previous(&tree_iter) { break; } } - let color = model.value(tree_iter, column_color).get::().unwrap(); + let color = model.value(&tree_iter, column_color).get::().unwrap(); if color == HEADER_ROW_COLOR { break; } } - tree_iter.clone() + model.path(&tree_iter).unwrap() } /// Populate bottom Scrolled View with small thumbnails @@ -569,7 +570,7 @@ fn update_bottom_buttons( } } -fn get_current_group_and_iter_from_selection(model: &TreeModel, selection: TreeSelection, column_color: i32) -> (u32, TreeIter) { +fn get_current_group_and_iter_from_selection(model: &TreeModel, selection: TreeSelection, column_color: i32) -> (u32, TreePath) { let mut current_group = 1; let mut possible_group = 1; let mut header_clone: TreeIter; @@ -601,5 +602,5 @@ fn get_current_group_and_iter_from_selection(model: &TreeModel, selection: TreeS } } - (current_group, header_clone) + (current_group, model.path(&header_clone).unwrap()) } diff --git a/czkawka_gui/src/connect_things/connect_button_hardlink.rs b/czkawka_gui/src/connect_things/connect_button_hardlink.rs index 2672480..594c033 100644 --- a/czkawka_gui/src/connect_things/connect_button_hardlink.rs +++ b/czkawka_gui/src/connect_things/connect_button_hardlink.rs @@ -193,9 +193,7 @@ pub fn hardlink_symlink( } } if hardlinking { - dbg!(&vec_symhardlink_data); for symhardlink_data in vec_symhardlink_data { - dbg!(&symhardlink_data); for file_to_hardlink in symhardlink_data.files_to_symhardlink { if let Err(e) = make_hard_link(&PathBuf::from(&symhardlink_data.original_data), &PathBuf::from(&file_to_hardlink)) { add_text_to_text_view(text_view_errors, format!("{} {}, reason {}", fl!("hardlink_failed"), file_to_hardlink, e).as_str()); diff --git a/czkawka_gui/src/gui_structs/gui_compare_images.rs b/czkawka_gui/src/gui_structs/gui_compare_images.rs index 0efda03..626ab1f 100644 --- a/czkawka_gui/src/gui_structs/gui_compare_images.rs +++ b/czkawka_gui/src/gui_structs/gui_compare_images.rs @@ -1,6 +1,6 @@ use czkawka_core::fl; use gtk::prelude::*; -use gtk::{Builder, TreeIter}; +use gtk::{Builder, TreePath}; use std::cell::RefCell; use std::rc::Rc; @@ -23,7 +23,7 @@ pub struct GuiCompareImages { pub shared_numbers_of_groups: Rc>, pub shared_current_of_groups: Rc>, - pub shared_current_iter: Rc>>, + pub shared_current_path: Rc>>, pub shared_image_cache: Rc>>, pub shared_using_for_preview: Rc, Option)>>, } @@ -53,7 +53,7 @@ impl GuiCompareImages { let shared_numbers_of_groups = Rc::new(RefCell::new(0)); let shared_current_of_groups = Rc::new(RefCell::new(0)); - let shared_current_iter = Rc::new(RefCell::new(None)); + let shared_current_path = Rc::new(RefCell::new(None)); let shared_image_cache = Rc::new(RefCell::new(Vec::new())); let shared_using_for_preview = Rc::new(RefCell::new((None, None))); @@ -69,7 +69,7 @@ impl GuiCompareImages { scrolled_window_compare_choose_images, shared_numbers_of_groups, shared_current_of_groups, - shared_current_iter, + shared_current_path, shared_image_cache, shared_using_for_preview, } diff --git a/czkawka_gui/ui/about_dialog.glade b/czkawka_gui/ui/about_dialog.glade index 3a2f111..4c1e037 100644 --- a/czkawka_gui/ui/about_dialog.glade +++ b/czkawka_gui/ui/about_dialog.glade @@ -43,7 +43,7 @@ Author: Rafał Mikrut This program is free to use and will always be. Rafał Mikrut(qarmin) - + help-about mit-x11