mirror of https://github.com/qarmin/czkawka
Clean GUI code, make it easier to understand and change (#462)
* Add static variable for basic notebook data * Opening, selecting results by space, enter and mouse * Now hard/symbolic links * Now deleting * Now popovers * Move tests to different function * Don't crash when there is no selected records * Button symlinks * Now move * Compute results * Move again * Again Popovers * More popovers and more * Key clicking, removing * KEY_DELETE * No more GuiData clone * Adding directories * Reorganize a little filespull/470/head
parent
78b49dee3d
commit
c9719758c7
@ -1,70 +0,0 @@
|
||||
use crate::connect_button_hardlink::hardlink_symlink;
|
||||
use crate::gui_data::GuiData;
|
||||
use crate::help_functions::*;
|
||||
use crate::notebook_enums::*;
|
||||
use gtk::prelude::*;
|
||||
|
||||
pub fn connect_button_symlink(gui_data: &GuiData) {
|
||||
let gui_data = gui_data.clone();
|
||||
|
||||
let buttons_symlink = gui_data.bottom_buttons.buttons_symlink.clone();
|
||||
let notebook_main = gui_data.main_notebook.notebook_main.clone();
|
||||
|
||||
let tree_view_duplicate_finder = gui_data.main_notebook.tree_view_duplicate_finder.clone();
|
||||
let tree_view_similar_images_finder = gui_data.main_notebook.tree_view_similar_images_finder.clone();
|
||||
let tree_view_similar_videos_finder = gui_data.main_notebook.tree_view_similar_videos_finder.clone();
|
||||
let tree_view_same_music_finder = gui_data.main_notebook.tree_view_same_music_finder.clone();
|
||||
|
||||
let image_preview_similar_images = gui_data.main_notebook.image_preview_similar_images.clone();
|
||||
let image_preview_duplicates = gui_data.main_notebook.image_preview_duplicates.clone();
|
||||
|
||||
buttons_symlink.connect_clicked(move |_| match to_notebook_main_enum(notebook_main.current_page().unwrap()) {
|
||||
NotebookMainEnum::Duplicate => {
|
||||
hardlink_symlink(
|
||||
tree_view_duplicate_finder.clone(),
|
||||
ColumnsDuplicates::Name as i32,
|
||||
ColumnsDuplicates::Path as i32,
|
||||
ColumnsDuplicates::Color as i32,
|
||||
ColumnsDuplicates::ActiveSelectButton as i32,
|
||||
false,
|
||||
&gui_data,
|
||||
);
|
||||
image_preview_duplicates.hide();
|
||||
}
|
||||
NotebookMainEnum::SameMusic => {
|
||||
hardlink_symlink(
|
||||
tree_view_same_music_finder.clone(),
|
||||
ColumnsSameMusic::Name as i32,
|
||||
ColumnsSameMusic::Path as i32,
|
||||
ColumnsSameMusic::Color as i32,
|
||||
ColumnsSameMusic::ActiveSelectButton as i32,
|
||||
false,
|
||||
&gui_data,
|
||||
);
|
||||
}
|
||||
NotebookMainEnum::SimilarImages => {
|
||||
hardlink_symlink(
|
||||
tree_view_similar_images_finder.clone(),
|
||||
ColumnsSimilarImages::Name as i32,
|
||||
ColumnsSimilarImages::Path as i32,
|
||||
ColumnsSimilarImages::Color as i32,
|
||||
ColumnsSimilarImages::ActiveSelectButton as i32,
|
||||
false,
|
||||
&gui_data,
|
||||
);
|
||||
image_preview_similar_images.hide();
|
||||
}
|
||||
NotebookMainEnum::SimilarVideos => {
|
||||
hardlink_symlink(
|
||||
tree_view_similar_videos_finder.clone(),
|
||||
ColumnsSimilarVideos::Name as i32,
|
||||
ColumnsSimilarVideos::Path as i32,
|
||||
ColumnsSimilarVideos::Color as i32,
|
||||
ColumnsSimilarVideos::ActiveSelectButton as i32,
|
||||
false,
|
||||
&gui_data,
|
||||
);
|
||||
}
|
||||
e => panic!("Not existent {:?}", e),
|
||||
});
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,187 +0,0 @@
|
||||
use crate::help_functions::*;
|
||||
use gtk::prelude::*;
|
||||
|
||||
const KEY_ENTER: u16 = 36;
|
||||
const KEY_SPACE: u16 = 65;
|
||||
|
||||
// TODO add option to open files and folders from context menu activated by pressing ONCE with right mouse button
|
||||
|
||||
pub fn opening_double_click_function_duplicates(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsDuplicates::Name as i32, ColumnsDuplicates::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsDuplicates::Name as i32, ColumnsDuplicates::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_duplicates(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsDuplicates::Name as u32, ColumnsDuplicates::Path as u32, ColumnsDuplicates::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_empty_folders(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsEmptyFolders::Name as i32, ColumnsEmptyFolders::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsEmptyFolders::Name as i32, ColumnsEmptyFolders::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_empty_folders(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsEmptyFolders::Name as u32, ColumnsEmptyFolders::Path as u32, ColumnsEmptyFolders::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_empty_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsEmptyFiles::Name as i32, ColumnsEmptyFiles::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsEmptyFiles::Name as i32, ColumnsEmptyFiles::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_empty_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsEmptyFiles::Name as u32, ColumnsEmptyFiles::Path as u32, ColumnsEmptyFiles::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_temporary_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsTemporaryFiles::Name as i32, ColumnsTemporaryFiles::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsTemporaryFiles::Name as i32, ColumnsTemporaryFiles::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_temporary_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsTemporaryFiles::Name as u32, ColumnsTemporaryFiles::Path as u32, ColumnsTemporaryFiles::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_big_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsBigFiles::Name as i32, ColumnsBigFiles::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsBigFiles::Name as i32, ColumnsBigFiles::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_big_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsBigFiles::Name as u32, ColumnsBigFiles::Path as u32, ColumnsBigFiles::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_same_music(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsSameMusic::Name as i32, ColumnsSameMusic::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsSameMusic::Name as i32, ColumnsSameMusic::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_same_music(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsSameMusic::Name as u32, ColumnsSameMusic::Path as u32, ColumnsSameMusic::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_similar_images(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsSimilarImages::Name as i32, ColumnsSimilarImages::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsSimilarImages::Name as i32, ColumnsSimilarImages::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
|
||||
pub fn opening_enter_function_similar_images(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsSimilarImages::Name as u32, ColumnsSimilarImages::Path as u32, ColumnsSimilarImages::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_similar_videos(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsSimilarVideos::Name as i32, ColumnsSimilarVideos::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsSimilarVideos::Name as i32, ColumnsSimilarVideos::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
|
||||
pub fn opening_enter_function_similar_videos(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsSimilarVideos::Name as u32, ColumnsSimilarVideos::Path as u32, ColumnsSimilarVideos::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_invalid_symlinks(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsInvalidSymlinks::Name as i32, ColumnsInvalidSymlinks::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsInvalidSymlinks::Name as i32, ColumnsInvalidSymlinks::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_invalid_symlinks(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsInvalidSymlinks::Name as u32, ColumnsInvalidSymlinks::Path as u32, ColumnsInvalidSymlinks::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
pub fn opening_double_click_function_broken_files(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, ColumnsBrokenFiles::Name as i32, ColumnsBrokenFiles::Path as i32, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, ColumnsBrokenFiles::Name as i32, ColumnsBrokenFiles::Path as i32, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function_broken_files(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
handle_tree_keypress(tree_view, event, ColumnsBrokenFiles::Name as u32, ColumnsBrokenFiles::Path as u32, ColumnsBrokenFiles::ActiveSelectButton as u32)
|
||||
}
|
||||
|
||||
enum OpenMode {
|
||||
OnlyPath,
|
||||
PathAndName,
|
||||
}
|
||||
|
||||
fn common_mark_function(tree_view: >k::TreeView, column_name: u32) {
|
||||
let selection = tree_view.selection();
|
||||
let (selection_rows, tree_model) = selection.selected_rows();
|
||||
|
||||
let model = get_list_store(tree_view);
|
||||
|
||||
for tree_path in selection_rows.iter().rev() {
|
||||
let value = !tree_model.value(&tree_model.iter(tree_path).unwrap(), column_name as i32).get::<bool>().unwrap();
|
||||
model.set_value(&tree_model.iter(tree_path).unwrap(), column_name, &value.to_value());
|
||||
}
|
||||
}
|
||||
|
||||
fn common_open_function(tree_view: >k::TreeView, column_name: i32, column_path: i32, opening_mode: OpenMode) {
|
||||
let selection = tree_view.selection();
|
||||
let (selection_rows, tree_model) = selection.selected_rows();
|
||||
|
||||
for tree_path in selection_rows.iter().rev() {
|
||||
let end_path;
|
||||
let name = tree_model.value(&tree_model.iter(tree_path).unwrap(), column_name).get::<String>().unwrap();
|
||||
let path = tree_model.value(&tree_model.iter(tree_path).unwrap(), column_path).get::<String>().unwrap();
|
||||
|
||||
match opening_mode {
|
||||
OpenMode::OnlyPath => {
|
||||
end_path = path;
|
||||
}
|
||||
OpenMode::PathAndName => {
|
||||
end_path = format!("{}/{}", path, name);
|
||||
}
|
||||
}
|
||||
|
||||
open::that_in_background(&end_path);
|
||||
|
||||
// if let Err(e) = open::that(&end_path) {
|
||||
// println!("Failed to open {} - Error {}", end_path, e);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_tree_keypress(tree_view: >k::TreeView, event: &gdk::EventKey, name_column: u32, path_column: u32, mark_column: u32) -> gtk::Inhibit {
|
||||
match event.keycode() {
|
||||
Some(KEY_ENTER) => {
|
||||
// Enter
|
||||
common_open_function(tree_view, name_column as i32, path_column as i32, OpenMode::PathAndName);
|
||||
}
|
||||
Some(KEY_SPACE) => {
|
||||
// Space
|
||||
common_mark_function(tree_view, mark_column);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
use crate::help_functions::*;
|
||||
use gtk::prelude::*;
|
||||
|
||||
const KEY_ENTER: u16 = 36;
|
||||
const KEY_SPACE: u16 = 65;
|
||||
|
||||
// TODO add option to open files and folders from context menu activated by pressing ONCE with right mouse button
|
||||
|
||||
pub fn opening_double_click_function(tree_view: >k::TreeView, event: &gdk::EventButton) -> gtk::Inhibit {
|
||||
let nt_object = get_notebook_object_from_tree_view(tree_view);
|
||||
if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 1 {
|
||||
common_open_function(tree_view, nt_object.column_name, nt_object.column_path, OpenMode::PathAndName);
|
||||
} else if event.event_type() == gdk::EventType::DoubleButtonPress && event.button() == 3 {
|
||||
common_open_function(tree_view, nt_object.column_name, nt_object.column_path, OpenMode::OnlyPath);
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
pub fn opening_enter_function(tree_view: >k::TreeView, event: &gdk::EventKey) -> gtk::Inhibit {
|
||||
let nt_object = get_notebook_object_from_tree_view(tree_view);
|
||||
handle_tree_keypress(tree_view, event, nt_object.column_name, nt_object.column_path, nt_object.column_selection)
|
||||
}
|
||||
|
||||
enum OpenMode {
|
||||
OnlyPath,
|
||||
PathAndName,
|
||||
}
|
||||
|
||||
fn common_mark_function(tree_view: >k::TreeView, column_name: i32) {
|
||||
let selection = tree_view.selection();
|
||||
let (selected_rows, tree_model) = selection.selected_rows();
|
||||
|
||||
let model = get_list_store(tree_view);
|
||||
|
||||
for tree_path in selected_rows.iter().rev() {
|
||||
let value = !tree_model.value(&tree_model.iter(tree_path).unwrap(), column_name).get::<bool>().unwrap();
|
||||
model.set_value(&tree_model.iter(tree_path).unwrap(), column_name as u32, &value.to_value());
|
||||
}
|
||||
}
|
||||
|
||||
fn common_open_function(tree_view: >k::TreeView, column_name: i32, column_path: i32, opening_mode: OpenMode) {
|
||||
let selection = tree_view.selection();
|
||||
let (selected_rows, tree_model) = selection.selected_rows();
|
||||
|
||||
for tree_path in selected_rows.iter().rev() {
|
||||
let end_path;
|
||||
let name = tree_model.value(&tree_model.iter(tree_path).unwrap(), column_name).get::<String>().unwrap();
|
||||
let path = tree_model.value(&tree_model.iter(tree_path).unwrap(), column_path).get::<String>().unwrap();
|
||||
|
||||
match opening_mode {
|
||||
OpenMode::OnlyPath => {
|
||||
end_path = path;
|
||||
}
|
||||
OpenMode::PathAndName => {
|
||||
end_path = format!("{}/{}", path, name);
|
||||
}
|
||||
}
|
||||
|
||||
open::that_in_background(&end_path);
|
||||
|
||||
// if let Err(e) = open::that(&end_path) {
|
||||
// println!("Failed to open {} - Error {}", end_path, e);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_tree_keypress(tree_view: >k::TreeView, event: &gdk::EventKey, name_column: i32, path_column: i32, mark_column: i32) -> gtk::Inhibit {
|
||||
match event.keycode() {
|
||||
Some(KEY_ENTER) => {
|
||||
// Enter
|
||||
common_open_function(tree_view, name_column, path_column, OpenMode::PathAndName);
|
||||
}
|
||||
Some(KEY_SPACE) => {
|
||||
// Space
|
||||
common_mark_function(tree_view, mark_column);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
gtk::Inhibit(false)
|
||||
}
|
||||
|
||||
pub fn select_function_duplicates(_tree_selection: >k::TreeSelection, tree_model: >k::TreeModel, tree_path: >k::TreePath, _is_path_currently_selected: bool) -> bool {
|
||||
// let name = tree_model.value(&tree_model.iter(tree_path).unwrap(),ColumnsDuplicates::Name as i32).get::<String>().unwrap();
|
||||
// let path = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsDuplicates::Path as i32).get::<String>().unwrap();
|
||||
// let modification = tree_model.value(&tree_model.iter(tree_path).unwrap(),ColumnsDuplicates::Modification as i32).get::<String>().unwrap();
|
||||
let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsDuplicates::Color as i32).get::<String>().unwrap();
|
||||
|
||||
if color == HEADER_ROW_COLOR {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
pub fn select_function_same_music(_tree_selection: >k::TreeSelection, tree_model: >k::TreeModel, tree_path: >k::TreePath, _is_path_currently_selected: bool) -> bool {
|
||||
let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSameMusic::Color as i32).get::<String>().unwrap();
|
||||
|
||||
if color == HEADER_ROW_COLOR {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
pub fn select_function_similar_images(_tree_selection: >k::TreeSelection, tree_model: >k::TreeModel, tree_path: >k::TreePath, _is_path_currently_selected: bool) -> bool {
|
||||
let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSimilarImages::Color as i32).get::<String>().unwrap();
|
||||
|
||||
if color == HEADER_ROW_COLOR {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
pub fn select_function_similar_videos(_tree_selection: >k::TreeSelection, tree_model: >k::TreeModel, tree_path: >k::TreePath, _is_path_currently_selected: bool) -> bool {
|
||||
let color = tree_model.value(&tree_model.iter(tree_path).unwrap(), ColumnsSimilarVideos::Color as i32).get::<String>().unwrap();
|
||||
|
||||
if color == HEADER_ROW_COLOR {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
use crate::help_functions::{get_notebook_enum_from_tree_view, NOTEBOOKS_INFOS};
|
||||
use crate::notebook_enums::{to_notebook_main_enum, NUMBER_OF_NOTEBOOK_MAIN_TABS};
|
||||
use crate::GuiData;
|
||||
|
||||
pub fn validate_notebook_data(gui_data: &GuiData) {
|
||||
// Test treeviews names, each treeview should have set name same as variable name
|
||||
let tree_view_arr: [>k::TreeView; NUMBER_OF_NOTEBOOK_MAIN_TABS] = [
|
||||
&gui_data.main_notebook.tree_view_duplicate_finder,
|
||||
&gui_data.main_notebook.tree_view_similar_videos_finder,
|
||||
&gui_data.main_notebook.tree_view_temporary_files_finder,
|
||||
&gui_data.main_notebook.tree_view_big_files_finder,
|
||||
&gui_data.main_notebook.tree_view_empty_files_finder,
|
||||
&gui_data.main_notebook.tree_view_broken_files,
|
||||
&gui_data.main_notebook.tree_view_empty_folder_finder,
|
||||
&gui_data.main_notebook.tree_view_same_music_finder,
|
||||
&gui_data.main_notebook.tree_view_similar_images_finder,
|
||||
&gui_data.main_notebook.tree_view_invalid_symlinks,
|
||||
];
|
||||
for (_i, item) in tree_view_arr.iter().enumerate() {
|
||||
// println!("Checking {} element", i);
|
||||
|
||||
get_notebook_enum_from_tree_view(item);
|
||||
}
|
||||
|
||||
// This test main info about notebooks
|
||||
// Should have same order as notebook enum types
|
||||
for (i, item) in NOTEBOOKS_INFOS.iter().enumerate() {
|
||||
let en = to_notebook_main_enum(i as u32);
|
||||
assert_eq!(item.notebook_type, en);
|
||||
}
|
||||
|
||||
// Tests if data returned from array get_notebook_enum_from_tree_view are in right
|
||||
for (i, item) in gui_data.main_notebook.get_main_tree_views().iter().enumerate() {
|
||||
let nb_en = get_notebook_enum_from_tree_view(item);
|
||||
assert_eq!(to_notebook_main_enum(i as u32), nb_en);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue