1
0
Fork 0
mirror of synced 2024-06-02 10:35:02 +12:00
This commit is contained in:
Rafał Mikrut 2022-05-19 21:02:09 +02:00
parent 48dd82a6a6
commit 4f9c65a3cf
9 changed files with 48 additions and 81 deletions

View file

@ -14,15 +14,15 @@ pub const RAW_IMAGE_EXTENSIONS: &[&str] = &[
".cr2", ".ari",
];
pub const IMAGE_RS_EXTENSIONS: &[&str] = &[
".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".webp", ".gif", ".ico", ".exr", ".hdr", "dds",
".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".webp", ".gif", ".ico", ".exr", ".hdr", ".dds",
];
pub const IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS: &[&str] = &[
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".bmp", ".webp", ".exr", ".hdr", "dds",
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".bmp", ".webp", ".exr", ".hdr", ".dds",
];
pub const IMAGE_RS_BROKEN_FILES_EXTENSIONS: &[&str] = &[
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".gif", ".bmp", ".ico", ".jfif", ".jpe", ".pnz", ".dib", ".webp", ".exr", ".hdr", "dds",
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".gif", ".bmp", ".ico", ".jfif", ".jpe", ".pnz", ".dib", ".webp", ".exr", ".hdr", ".dds",
];
pub const ZIP_FILES_EXTENSIONS: &[&str] = &[".zip"];

View file

@ -1,7 +1,7 @@
use gtk4::prelude::*;
use gtk4::Widget;
use crate::help_functions::{get_custom_label_from_button_with_image, set_icon_of_button, set_icon_of_menubutton, BottomButtonsEnum};
use crate::help_functions::{get_custom_label_from_button_with_image, set_icon_of_button, BottomButtonsEnum};
use crate::{
flg, CZK_ICON_COMPARE, CZK_ICON_HARDLINK, CZK_ICON_HIDE_DOWN, CZK_ICON_HIDE_UP, CZK_ICON_MOVE, CZK_ICON_SAVE, CZK_ICON_SEARCH, CZK_ICON_SELECT, CZK_ICON_SYMLINK,
CZK_ICON_TRASH,
@ -36,17 +36,17 @@ impl GuiBottomButtons {
let buttons_show_errors: gtk4::Button = builder.object("buttons_show_errors").unwrap();
let buttons_show_upper_notebook: gtk4::Button = builder.object("buttons_show_upper_notebook").unwrap();
// TODO GTK 4
// set_icon_of_button(&buttons_search, CZK_ICON_SEARCH);
// set_icon_of_menubutton(&buttons_select, CZK_ICON_SELECT);
// set_icon_of_button(&buttons_delete, CZK_ICON_TRASH);
// set_icon_of_button(&buttons_save, CZK_ICON_SAVE);
// set_icon_of_button(&buttons_symlink, CZK_ICON_SYMLINK);
// set_icon_of_button(&buttons_hardlink, CZK_ICON_HARDLINK);
// set_icon_of_button(&buttons_move, CZK_ICON_MOVE);
// set_icon_of_button(&buttons_compare, CZK_ICON_COMPARE);
// set_icon_of_button(&buttons_show_errors, CZK_ICON_HIDE_DOWN);
// set_icon_of_button(&buttons_show_upper_notebook, CZK_ICON_HIDE_UP);
set_icon_of_button(&buttons_search, CZK_ICON_SEARCH);
set_icon_of_button(&buttons_select, CZK_ICON_SELECT);
set_icon_of_button(&buttons_delete, CZK_ICON_TRASH);
set_icon_of_button(&buttons_save, CZK_ICON_SAVE);
set_icon_of_button(&buttons_symlink, CZK_ICON_SYMLINK);
set_icon_of_button(&buttons_hardlink, CZK_ICON_HARDLINK);
set_icon_of_button(&buttons_move, CZK_ICON_MOVE);
set_icon_of_button(&buttons_compare, CZK_ICON_COMPARE);
set_icon_of_button(&buttons_show_errors, CZK_ICON_HIDE_DOWN);
set_icon_of_button(&buttons_show_upper_notebook, CZK_ICON_HIDE_UP);
let buttons_names = [
BottomButtonsEnum::Search,
@ -87,14 +87,13 @@ impl GuiBottomButtons {
}
}
pub fn update_language(&self) {
// TODO GTK 4
// get_custom_label_from_button_with_image(&self.buttons_search.clone()).set_text(&flg!("bottom_search_button"));
// get_custom_label_from_button_with_image(&self.buttons_select.clone()).set_text(&flg!("bottom_select_button"));
// get_custom_label_from_button_with_image(&self.buttons_delete.clone()).set_text(&flg!("bottom_delete_button"));
// get_custom_label_from_button_with_image(&self.buttons_save.clone()).set_text(&flg!("bottom_save_button"));
// get_custom_label_from_button_with_image(&self.buttons_symlink.clone()).set_text(&flg!("bottom_symlink_button"));
// get_custom_label_from_button_with_image(&self.buttons_hardlink.clone()).set_text(&flg!("bottom_hardlink_button"));
// get_custom_label_from_button_with_image(&self.buttons_move.clone()).set_text(&flg!("bottom_move_button"));
get_custom_label_from_button_with_image(&self.buttons_search.clone()).set_text(&flg!("bottom_search_button"));
get_custom_label_from_button_with_image(&self.buttons_select.clone()).set_text(&flg!("bottom_select_button"));
get_custom_label_from_button_with_image(&self.buttons_delete.clone()).set_text(&flg!("bottom_delete_button"));
get_custom_label_from_button_with_image(&self.buttons_save.clone()).set_text(&flg!("bottom_save_button"));
get_custom_label_from_button_with_image(&self.buttons_symlink.clone()).set_text(&flg!("bottom_symlink_button"));
get_custom_label_from_button_with_image(&self.buttons_hardlink.clone()).set_text(&flg!("bottom_hardlink_button"));
get_custom_label_from_button_with_image(&self.buttons_move.clone()).set_text(&flg!("bottom_move_button"));
self.buttons_search.set_tooltip_text(Some(&flg!("bottom_search_button_tooltip")));
self.buttons_select.set_tooltip_text(Some(&flg!("bottom_select_button_tooltip")));

View file

@ -58,9 +58,8 @@ impl GuiCompareImages {
let shared_image_cache = Rc::new(RefCell::new(Vec::new()));
let shared_using_for_preview = Rc::new(RefCell::new((None, None)));
// TODO GTK 4
// set_icon_of_button(&button_go_previous_compare_group, CZK_ICON_LEFT);
// set_icon_of_button(&button_go_next_compare_group, CZK_ICON_RIGHT);
set_icon_of_button(&button_go_previous_compare_group, CZK_ICON_LEFT);
set_icon_of_button(&button_go_next_compare_group, CZK_ICON_RIGHT);
Self {
window_compare,

View file

@ -14,9 +14,8 @@ impl GuiHeader {
let button_settings: gtk4::Button = builder.object("button_settings").unwrap();
let button_app_info: gtk4::Button = builder.object("button_app_info").unwrap();
// TODO GTK 4
// set_icon_of_button(&button_settings, CZK_ICON_SETTINGS);
// set_icon_of_button(&button_app_info, CZK_ICON_INFO);
set_icon_of_button(&button_settings, CZK_ICON_SETTINGS);
set_icon_of_button(&button_app_info, CZK_ICON_INFO);
Self { button_settings, button_app_info }
}

View file

@ -145,7 +145,6 @@ impl GuiMainNotebook {
let tree_view_broken_files: gtk4::TreeView = TreeView::new();
let tree_view_bad_extensions: gtk4::TreeView = TreeView::new();
// TODO GTK 4
let evk_tree_view_duplicate_finder: gtk4::EventControllerKey = EventControllerKey::new();
tree_view_duplicate_finder.add_controller(&evk_tree_view_duplicate_finder);
let evk_tree_view_empty_folder_finder: gtk4::EventControllerKey = EventControllerKey::new();

View file

@ -47,7 +47,6 @@ impl GuiProgressDialog {
let gc_button_stop_in_dialog = gtk4::GestureClick::new();
button_stop_in_dialog.add_controller(&gc_button_stop_in_dialog);
// TODO GTK 4
set_icon_of_button(&button_stop_in_dialog, CZK_ICON_STOP);
Self {

View file

@ -84,13 +84,12 @@ impl GuiUpperNotebook {
let label_general_min_size: gtk4::Label = builder.object("label_general_min_size").unwrap();
let label_general_max_size: gtk4::Label = builder.object("label_general_max_size").unwrap();
// TODO GTK 4
// set_icon_of_button(&buttons_add_included_directory, CZK_ICON_ADD);
// set_icon_of_button(&buttons_manual_add_included_directory, CZK_ICON_MANUAL_ADD);
// set_icon_of_button(&buttons_remove_included_directory, CZK_ICON_DELETE);
// set_icon_of_button(&buttons_add_excluded_directory, CZK_ICON_ADD);
// set_icon_of_button(&buttons_manual_add_excluded_directory, CZK_ICON_MANUAL_ADD);
// set_icon_of_button(&buttons_remove_excluded_directory, CZK_ICON_DELETE);
set_icon_of_button(&buttons_add_included_directory, CZK_ICON_ADD);
set_icon_of_button(&buttons_manual_add_included_directory, CZK_ICON_MANUAL_ADD);
set_icon_of_button(&buttons_remove_included_directory, CZK_ICON_DELETE);
set_icon_of_button(&buttons_add_excluded_directory, CZK_ICON_ADD);
set_icon_of_button(&buttons_manual_add_excluded_directory, CZK_ICON_MANUAL_ADD);
set_icon_of_button(&buttons_remove_excluded_directory, CZK_ICON_DELETE);
Self {
notebook_upper,

View file

@ -797,51 +797,30 @@ pub fn get_max_file_name(file_name: &str, max_length: usize) -> String {
// GTK 4
pub fn get_custom_label_from_button_with_image<P: IsA<gtk4::Widget>>(button: &P) -> gtk4::Label {
let internal_box = button.first_child().unwrap().downcast::<gtk4::Box>().unwrap();
for child in get_all_children(&internal_box) {
if let Ok(t) = child.downcast::<gtk4::Label>() {
return t;
let mut widgets_to_check = vec![button.clone().upcast::<gtk4::Widget>()];
while let Some(widget) = widgets_to_check.pop() {
if let Ok(label) = widget.clone().downcast::<gtk4::Label>() {
return label;
} else {
widgets_to_check.extend(get_all_children(&widget));
}
}
panic!("Button doesn't have proper custom label child");
}
pub fn get_custom_image_from_button_with_image<P: IsA<gtk4::Widget>>(button: &P) -> gtk4::Image {
let internal_box = button.first_child().unwrap().downcast::<gtk4::Box>().unwrap();
for child in get_all_children(&internal_box) {
if let Ok(t) = child.downcast::<gtk4::Image>() {
return t;
let mut widgets_to_check = vec![button.clone().upcast::<gtk4::Widget>()];
while let Some(widget) = widgets_to_check.pop() {
if let Ok(image) = widget.clone().downcast::<gtk4::Image>() {
return image;
} else {
widgets_to_check.extend(get_all_children(&widget));
}
}
panic!("Button doesn't have proper custom label child");
}
pub fn get_custom_label_from_menubutton_with_image<P: IsA<gtk4::Widget>>(button: &P) -> gtk4::Label {
println!("{:?}", get_all_children(button));
for c1 in get_all_children(button) {
if let Ok(internal_box) = c1.downcast::<gtk4::Box>() {
for child in get_all_children(&internal_box) {
if let Ok(t) = child.downcast::<gtk4::Label>() {
return t;
}
}
}
}
panic!("Menu Button doesn't have proper custom label child");
}
pub fn get_custom_image_from_menubutton_with_image<P: IsA<gtk4::Widget>>(button: &P) -> gtk4::Image {
println!("{:?}", get_all_children(button));
for c1 in get_all_children(button) {
if let Ok(internal_box) = c1.downcast::<gtk4::Box>() {
for child in get_all_children(&internal_box) {
if let Ok(t) = child.downcast::<gtk4::Image>() {
return t;
}
}
}
}
panic!("Menu Button doesn't have proper custom label child");
}
// GTK 4
pub fn get_all_children<P: IsA<gtk4::Widget>>(wid: &P) -> Vec<gtk4::Widget> {
let mut vector = vec![];
@ -862,15 +841,9 @@ pub fn get_all_children<P: IsA<gtk4::Widget>>(wid: &P) -> Vec<gtk4::Widget> {
const SIZE_OF_ICON: i32 = 18;
const TYPE_OF_INTERPOLATION: InterpType = InterpType::Tiles;
pub fn set_icon_of_button(button: &gtk4::Button, data: &'static [u8]) {
pub fn set_icon_of_button<P: IsA<gtk4::Widget>>(button: &P, data: &'static [u8]) {
let image = get_custom_image_from_button_with_image(&button.clone());
let pixbuf = Pixbuf::from_read(std::io::BufReader::new(data)).unwrap();
let pixbuf = pixbuf.scale_simple(SIZE_OF_ICON, SIZE_OF_ICON, TYPE_OF_INTERPOLATION).unwrap();
image.set_from_pixbuf(Some(&pixbuf));
}
pub fn set_icon_of_menubutton(button: &gtk4::MenuButton, data: &'static [u8]) {
let image = get_custom_image_from_menubutton_with_image(&button.clone());
let pixbuf = Pixbuf::from_read(std::io::BufReader::new(data)).unwrap();
let pixbuf = pixbuf.scale_simple(SIZE_OF_ICON, SIZE_OF_ICON, TYPE_OF_INTERPOLATION).unwrap();
image.set_from_pixbuf(Some(&pixbuf));
}

View file

@ -728,7 +728,7 @@ fn show_preview(
Some(pixbuf) => pixbuf,
};
image_preview.set_from_pixbuf(Some(&pixbuf)); // TODO GTK 4
image_preview.set_from_pixbuf(Some(&pixbuf));
{
let mut preview_path = preview_path.borrow_mut();
*preview_path = file_name.to_string();