Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More GTK 4 related changes #474

Merged
merged 3 commits into from
Dec 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More changes
  • Loading branch information
qarmin committed Nov 30, 2021

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 5acad42385e5d9e11bf7c1333fbcf0422842d2b8
24 changes: 12 additions & 12 deletions czkawka_gui/src/connect_button_delete.rs
Original file line number Diff line number Diff line change
@@ -97,9 +97,9 @@ pub async fn check_if_can_delete_files(check_button_settings_confirm_deletion: &
}

fn create_dialog_ask_for_deletion(window_main: &gtk::Window) -> (Dialog, CheckButton) {
let confirmation_dialog_delete = gtk::Dialog::builder().title("Delete confirmation").transient_for(window_main).build();
let button_ok = confirmation_dialog_delete.add_button("Ok", ResponseType::Ok);
confirmation_dialog_delete.add_button("Close", ResponseType::Cancel);
let dialog = gtk::Dialog::builder().title("Delete confirmation").transient_for(window_main).build();
let button_ok = dialog.add_button("Ok", ResponseType::Ok);
dialog.add_button("Close", ResponseType::Cancel);

let label: gtk::Label = gtk::Label::new(Some("Are you sure that you want to delete files?"));
let check_button: gtk::CheckButton = gtk::CheckButton::with_label("Ask next time");
@@ -108,18 +108,18 @@ fn create_dialog_ask_for_deletion(window_main: &gtk::Window) -> (Dialog, CheckBu

button_ok.grab_focus();

let internal_box = get_dialog_box_child(&confirmation_dialog_delete);
let internal_box = get_dialog_box_child(&dialog);
internal_box.add(&label);
internal_box.add(&check_button);

confirmation_dialog_delete.show_all();
(confirmation_dialog_delete, check_button)
dialog.show_all();
(dialog, check_button)
}

fn create_dialog_group_deletion(window_main: &gtk::Window) -> (Dialog, CheckButton) {
let confirmation_dialog_group_delete = gtk::Dialog::builder().title("Confirmation of deleting all files in group").transient_for(window_main).build();
let button_ok = confirmation_dialog_group_delete.add_button("Ok", ResponseType::Ok);
confirmation_dialog_group_delete.add_button("Close", ResponseType::Cancel);
let dialog = gtk::Dialog::builder().title("Confirmation of deleting all files in group").transient_for(window_main).build();
let button_ok = dialog.add_button("Ok", ResponseType::Ok);
dialog.add_button("Close", ResponseType::Cancel);

let label: gtk::Label = gtk::Label::new(Some("In some groups there are selected all records."));
let label2: gtk::Label = gtk::Label::new(Some("Are you sure that you want to delete them?"));
@@ -129,13 +129,13 @@ fn create_dialog_group_deletion(window_main: &gtk::Window) -> (Dialog, CheckButt

button_ok.grab_focus();

let internal_box = get_dialog_box_child(&confirmation_dialog_group_delete);
let internal_box = get_dialog_box_child(&dialog);
internal_box.add(&label);
internal_box.add(&label2);
internal_box.add(&check_button);

confirmation_dialog_group_delete.show_all();
(confirmation_dialog_group_delete, check_button)
dialog.show_all();
(dialog, check_button)
}

pub async fn check_if_deleting_all_files_in_group(tree_view: &gtk::TreeView, column_color: i32, column_selection: i32, window_main: &gtk::Window, check_button_settings_confirm_group_deletion: &gtk::CheckButton) -> bool {
8 changes: 4 additions & 4 deletions czkawka_gui/src/connect_button_stop.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use gtk::prelude::*;

use crate::gui_data::GuiData;
use crate::help_functions::KEY_ENTER;

pub fn connect_button_stop(gui_data: &GuiData) {
let button_stop_in_dialog = gui_data.progress_window.button_stop_in_dialog.clone();
let evk_button_stop_in_dialog = gui_data.progress_window.evk_button_stop_in_dialog.clone();
let stop_sender = gui_data.stop_sender.clone();
button_stop_in_dialog.connect_key_release_event(move |_, e| {
if e.keycode() == Some(36) {
evk_button_stop_in_dialog.connect_key_released(move |_, _, key_code, _| {
if key_code == KEY_ENTER {
// Only accept enter key to stop search
stop_sender.send(()).unwrap();
}
gtk::Inhibit(false)
});

let button_stop_in_dialog = gui_data.progress_window.button_stop_in_dialog.clone();
4 changes: 2 additions & 2 deletions czkawka_gui/src/connect_header_buttons.rs
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ pub fn connect_button_about(gui_data: &GuiData) {
about_dialog.show();

// Prevent from deleting dialog after close
about_dialog.connect_delete_event(|e, _f| {
e.hide();
about_dialog.connect_delete_event(|dialog, _| {
dialog.hide();
Inhibit(true)
});
});
14 changes: 7 additions & 7 deletions czkawka_gui/src/connect_popovers.rs
Original file line number Diff line number Diff line change
@@ -227,11 +227,11 @@ fn popover_custom_select_unselect(popover: &gtk::Popover, window_main: &Window,
true => "Select Custom",
};

// Accept Dialog
// Dialog for select/unselect items
{
let confirmation_dialog_select_unselect = gtk::Dialog::builder().title(window_title).transient_for(window_main).build();
confirmation_dialog_select_unselect.add_button("Ok", ResponseType::Ok);
confirmation_dialog_select_unselect.add_button("Close", ResponseType::Cancel);
let dialog = gtk::Dialog::builder().title(window_title).transient_for(window_main).build();
dialog.add_button("Ok", ResponseType::Ok);
dialog.add_button("Close", ResponseType::Cancel);

let label: gtk::Label = gtk::Label::new(Some("Usage: */folder-nr*/* or name-version-*.txt"));

@@ -264,13 +264,13 @@ fn popover_custom_select_unselect(popover: &gtk::Popover, window_main: &Window,
grid.attach(&entry_name, 1, 2, 1, 1);
grid.attach(&entry_name_path, 1, 3, 1, 1);

let box_widget = get_dialog_box_child(&confirmation_dialog_select_unselect);
let box_widget = get_dialog_box_child(&dialog);
box_widget.add(&grid);

confirmation_dialog_select_unselect.show_all();
dialog.show_all();

let tree_view = tree_view.clone();
confirmation_dialog_select_unselect.connect_response(move |confirmation_dialog_select_unselect, response_type| {
dialog.connect_response(move |confirmation_dialog_select_unselect, response_type| {
let wildcard_type: WildcardType;
let wildcard: String;

14 changes: 7 additions & 7 deletions czkawka_gui/src/connect_selection_of_directories.rs
Original file line number Diff line number Diff line change
@@ -103,18 +103,18 @@ fn add_chosen_directories(window_main: &Window, tree_view: &TreeView, excluded_i
}

fn add_manually_directories(window_main: &Window, tree_view: &TreeView) {
let dialog_manual_add_directory = gtk::Dialog::builder().title("Add directory manually").transient_for(window_main).build();
dialog_manual_add_directory.add_button("Ok", ResponseType::Ok);
dialog_manual_add_directory.add_button("Close", ResponseType::Cancel);
let dialog = gtk::Dialog::builder().title("Add directory manually").transient_for(window_main).build();
dialog.add_button("Ok", ResponseType::Ok);
dialog.add_button("Close", ResponseType::Cancel);

let entry: gtk::Entry = gtk::Entry::new();

get_dialog_box_child(&dialog_manual_add_directory).add(&entry);
get_dialog_box_child(&dialog).add(&entry);

dialog_manual_add_directory.show_all();
dialog.show_all();

let tree_view = tree_view.clone();
dialog_manual_add_directory.connect_response(move |dialog_manual_add_directory, response_type| {
dialog.connect_response(move |dialog, response_type| {
if response_type == gtk::ResponseType::Ok {
let text = entry.text().to_string().trim().to_string();

@@ -128,6 +128,6 @@ fn add_manually_directories(window_main: &Window, tree_view: &TreeView) {
list_store.set(&list_store.append(), &values);
}
}
dialog_manual_add_directory.close();
dialog.close();
});
}
2 changes: 1 addition & 1 deletion czkawka_gui/src/connect_settings.rs
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ pub fn connect_settings(gui_data: &GuiData) {
let window_main = gui_data.window_main.clone();
let window_settings = gui_data.settings.window_settings.clone();

window_settings.connect_delete_event(move |window, _y| {
window_settings.connect_delete_event(move |window, _| {
window.hide();
window_main.set_sensitive(true);
gtk::Inhibit(true)
6 changes: 3 additions & 3 deletions czkawka_gui/src/connect_similar_image_size_change.rs
Original file line number Diff line number Diff line change
@@ -9,23 +9,23 @@ pub fn connect_similar_image_size_change(gui_data: &GuiData) {
{
let radio_button_similar_hash_size_4 = gui_data.main_notebook.radio_button_similar_hash_size_4.clone();
let scale_similarity_similar_images = gui_data.main_notebook.scale_similarity_similar_images.clone();
radio_button_similar_hash_size_4.connect_clicked(move |_| {
radio_button_similar_hash_size_4.connect_toggled(move |_| {
scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[0][5] as f64);
scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[0][5] as f64);
});
}
{
let radio_button_similar_hash_size_8 = gui_data.main_notebook.radio_button_similar_hash_size_8.clone();
let scale_similarity_similar_images = gui_data.main_notebook.scale_similarity_similar_images.clone();
radio_button_similar_hash_size_8.connect_clicked(move |_| {
radio_button_similar_hash_size_8.connect_toggled(move |_| {
scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[1][5] as f64);
scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[1][5] as f64);
});
}
{
let radio_button_similar_hash_size_16 = gui_data.main_notebook.radio_button_similar_hash_size_16.clone();
let scale_similarity_similar_images = gui_data.main_notebook.scale_similarity_similar_images.clone();
radio_button_similar_hash_size_16.connect_clicked(move |_| {
radio_button_similar_hash_size_16.connect_toggled(move |_| {
scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[2][5] as f64);
scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[2][5] as f64);
});
22 changes: 22 additions & 0 deletions czkawka_gui/src/gui_main_notebook.rs
Original file line number Diff line number Diff line change
@@ -130,6 +130,28 @@ impl GuiMainNotebook {
let evk_tree_view_invalid_symlinks: gtk::EventControllerKey = EventControllerKey::new(&tree_view_invalid_symlinks);
let evk_tree_view_broken_files: gtk::EventControllerKey = EventControllerKey::new(&tree_view_broken_files);

// 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();
// tree_view_empty_folder_finder.add_controller(&evk_tree_view_empty_folder_finder);
// let evk_tree_view_empty_files_finder: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_empty_files_finder.add_controller(&evk_tree_view_empty_files_finder);
// let evk_tree_view_temporary_files_finder: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_temporary_files_finder.add_controller(&evk_tree_view_temporary_files_finder);
// let evk_tree_view_big_files_finder: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_big_files_finder.add_controller(&evk_tree_view_big_files_finder);
// let evk_tree_view_similar_images_finder: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_similar_images_finder.add_controller(&evk_tree_view_similar_images_finder);
// let evk_tree_view_similar_videos_finder: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_similar_videos_finder.add_controller(&evk_tree_view_similar_videos_finder);
// let evk_tree_view_same_music_finder: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_same_music_finder.add_controller(&evk_tree_view_same_music_finder);
// let evk_tree_view_invalid_symlinks: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_invalid_symlinks.add_controller(&evk_tree_view_invalid_symlinks);
// let evk_tree_view_broken_files: gtk4::EventControllerKey = EventControllerKey::new();
// tree_view_broken_files.add_controller(&evk_tree_view_broken_files);

let entry_similar_images_minimal_size: gtk::Entry = builder.object("entry_similar_images_minimal_size").unwrap();
let entry_similar_images_maximal_size: gtk::Entry = builder.object("entry_similar_images_maximal_size").unwrap();
let entry_similar_videos_minimal_size: gtk::Entry = builder.object("entry_similar_videos_minimal_size").unwrap();
5 changes: 4 additions & 1 deletion czkawka_gui/src/gui_progress_dialog.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use gtk::prelude::*;
use gtk::{Builder, Window};
use gtk::{Builder, EventControllerKey, Window};

#[derive(Clone)]
pub struct GuiProgressDialog {
@@ -13,6 +13,7 @@ pub struct GuiProgressDialog {
pub grid_progress_stages: gtk::Grid,

pub button_stop_in_dialog: gtk::Button,
pub evk_button_stop_in_dialog: gtk::EventControllerKey,
}

impl GuiProgressDialog {
@@ -31,6 +32,7 @@ impl GuiProgressDialog {
let grid_progress_stages: gtk::Grid = builder.object("grid_progress_stages").unwrap();

let button_stop_in_dialog: gtk::Button = builder.object("button_stop_in_dialog").unwrap();
let evk_button_stop_in_dialog = EventControllerKey::new(&button_stop_in_dialog);

Self {
window_progress,
@@ -39,6 +41,7 @@ impl GuiProgressDialog {
label_stage,
grid_progress_stages,
button_stop_in_dialog,
evk_button_stop_in_dialog,
}
}
}
2 changes: 1 addition & 1 deletion czkawka_gui/src/initialize_gui.rs
Original file line number Diff line number Diff line change
@@ -467,7 +467,7 @@ pub fn initialize_gui(gui_data: &mut GuiData) {
let window_progress = gui_data.progress_window.window_progress.clone();
let stop_sender = gui_data.stop_sender.clone();

window_progress.connect_delete_event(move |_e, _y| {
window_progress.connect_delete_event(move |_, _| {
stop_sender.send(()).unwrap();
gtk::Inhibit(true)
});