1
0
Fork 0
mirror of synced 2024-04-28 17:42:26 +12:00

Remove GTK warning (#587)

This commit is contained in:
Rafał Mikrut 2022-01-16 17:54:44 +01:00 committed by GitHub
parent d310fe4059
commit 9197edcf16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 40 deletions

View file

@ -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::<ListStore>().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::<ListStore>().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<RefCell<Option<TreeIter>>>,
tree_iter: TreeIter,
shared_current_path: Rc<RefCell<Option<TreePath>>>,
tree_path: TreePath,
image_compare_left: &gtk::Image,
image_compare_right: &gtk::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::<String>().unwrap(), HEADER_ROW_COLOR);
let using_reference = !model.value(&used_iter, column_path).get::<String>().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: &gtk::TreeModel, tree_iter: &TreeIter, column_color: i32, go_next: bool) -> TreeIter {
assert_eq!(model.value(tree_iter, column_color).get::<String>().unwrap(), HEADER_ROW_COLOR);
fn move_iter(model: &gtk::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::<String>().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::<String>().unwrap();
let color = model.value(&tree_iter, column_color).get::<String>().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())
}

View file

@ -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());

View file

@ -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<RefCell<u32>>,
pub shared_current_of_groups: Rc<RefCell<u32>>,
pub shared_current_iter: Rc<RefCell<Option<TreeIter>>>,
pub shared_current_path: Rc<RefCell<Option<TreePath>>>,
pub shared_image_cache: Rc<RefCell<Vec<(String, String, gtk::Image, gtk::Image, gtk::TreePath)>>>,
pub shared_using_for_preview: Rc<RefCell<(Option<gtk::TreePath>, Option<gtk::TreePath>)>>,
}
@ -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,
}

View file

@ -43,7 +43,7 @@ Author: Rafał Mikrut
This program is free to use and will always be.
</property>
<property name="authors">Rafał Mikrut(qarmin)</property>
<property name="logo"/>
<property name="logo-icon-name">help-about</property>
<property name="license-type">mit-x11</property>
<child internal-child="vbox">
<object class="GtkBox">