1
0
Fork 0
mirror of synced 2024-04-27 17:22:13 +12:00

Add new settings window (#262)

This commit is contained in:
Rafał Mikrut 2021-02-23 09:40:19 +01:00 committed by GitHub
parent 4c770b582b
commit 35c47b3230
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 433 additions and 265 deletions

View file

@ -950,148 +950,6 @@ This program is free to use and will always be.
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<!-- n-columns=4 n-rows=3 -->
<object class="GtkGrid" id="notebook_upper_settings">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="column-homogeneous">True</property>
<child>
<object class="GtkCheckButton" id="check_button_settings_save_at_exit">
<property name="label" translatable="yes">Save configuration at exit</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_settings_save_configuration">
<property name="label" translatable="yes">Save current configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_settings_load_configuration">
<property name="label" translatable="yes">Load configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_settings_reset_configuration">
<property name="label" translatable="yes">Reset configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_button_settings_load_at_start">
<property name="label" translatable="yes">Load configuration at start</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_button_settings_confirm_deletion">
<property name="label" translatable="yes">Show confirm dialog when deleting</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_button_settings_show_preview_similar_images">
<property name="label" translatable="yes">Show image preview</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_button_settings_show_text_view">
<property name="label" translatable="yes">Show bottom text panel</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Settings</property>
</object>
<packing>
<property name="position">4</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
@ -1153,13 +1011,10 @@ This program is free to use and will always be.
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkRadioButton" id="radio_button_duplicates_name">
<property name="label" translatable="yes">Name (very fast)</property>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">radio_button_duplicates_hash</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Check method:</property>
</object>
<packing>
<property name="expand">False</property>
@ -1168,13 +1023,13 @@ This program is free to use and will always be.
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_button_duplicates_size">
<property name="label" translatable="yes">Size (very fast)</property>
<object class="GtkRadioButton" id="radio_button_duplicates_hash">
<property name="label" translatable="yes">Hash</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">radio_button_duplicates_hash</property>
</object>
<packing>
<property name="expand">False</property>
@ -1184,7 +1039,7 @@ This program is free to use and will always be.
</child>
<child>
<object class="GtkRadioButton" id="radio_button_duplicates_hashmb">
<property name="label" translatable="yes">HashMb (fast)</property>
<property name="label" translatable="yes">HashMb</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
@ -1198,13 +1053,13 @@ This program is free to use and will always be.
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_button_duplicates_hash">
<property name="label" translatable="yes">Hash (slow but accurate)</property>
<object class="GtkRadioButton" id="radio_button_duplicates_size">
<property name="label" translatable="yes">Size</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
<property name="group">radio_button_duplicates_hash</property>
</object>
<packing>
<property name="expand">False</property>
@ -1212,6 +1067,21 @@ This program is free to use and will always be.
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_button_duplicates_name">
<property name="label" translatable="yes">Name</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<property name="group">radio_button_duplicates_hash</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -2394,7 +2264,7 @@ This program is free to use and will always be.
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<!-- n-columns=2 n-rows=2 -->
<object class="GtkGrid" id="grid_progress_stages">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -2444,21 +2314,6 @@ This program is free to use and will always be.
<property name="top-attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
@ -2479,24 +2334,106 @@ This program is free to use and will always be.
</packing>
</child>
<child>
<object class="GtkButtonBox">
<object class="GtkButton" id="button_stop_in_dialog">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">end</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">dialog-cancel</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Stop</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="window_settings">
<property name="can-focus">False</property>
<property name="title" translatable="yes">Czkawka Options</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="button_stop_in_dialog">
<object class="GtkComboBoxText">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkNotebook">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tab-pos">left</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage">
<object class="GtkCheckButton" id="check_button_settings_load_at_start">
<property name="label" translatable="yes">Load configuration at start</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">dialog-cancel</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -2505,33 +2442,200 @@ This program is free to use and will always be.
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkCheckButton" id="check_button_settings_confirm_deletion">
<property name="label" translatable="yes">Show confirm dialog when deleting</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Stop</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_button_settings_show_text_view">
<property name="label" translatable="yes">Show bottom text panel</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_button_settings_save_at_exit">
<property name="label" translatable="yes">Save configuration at exit</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">General</property>
</object>
<packing>
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="check_button_settings_hide_hard_links">
<property name="label" translatable="yes">Hide hard links</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Duplicate Finder</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="check_button_settings_show_preview_similar_images">
<property name="label" translatable="yes">Show image preview</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Similar Images</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">3</property>
<property name="margin-end">3</property>
<property name="spacing">3</property>
<child>
<object class="GtkButton" id="button_settings_load_configuration">
<property name="label" translatable="yes">Load configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkButton" id="button_settings_reset_configuration">
<property name="label" translatable="yes">Reset configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_settings_save_configuration">
<property name="label" translatable="yes">Save configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">2</property>
</packing>
</child>

View file

@ -24,7 +24,7 @@ pub fn connect_button_delete(gui_data: &GuiData) {
let tree_view_same_music_finder = gui_data.main_notebook.tree_view_same_music_finder.clone();
let tree_view_invalid_symlinks = gui_data.main_notebook.tree_view_invalid_symlinks.clone();
let tree_view_broken_files = gui_data.main_notebook.tree_view_broken_files.clone();
let check_button_settings_confirm_deletion = gui_data.upper_notebook.check_button_settings_confirm_deletion.clone();
let check_button_settings_confirm_deletion = gui_data.settings.check_button_settings_confirm_deletion.clone();
let image_preview_similar_images = gui_data.main_notebook.image_preview_similar_images.clone();
buttons_delete.connect_clicked(move |_| {

View file

@ -90,6 +90,7 @@ pub fn connect_button_search(
let radio_button_hash_type_blake3 = gui_data.main_notebook.radio_button_hash_type_blake3.clone();
let radio_button_hash_type_crc32 = gui_data.main_notebook.radio_button_hash_type_crc32.clone();
let radio_button_hash_type_xxh3 = gui_data.main_notebook.radio_button_hash_type_xxh3.clone();
let check_button_settings_hide_hard_links = gui_data.settings.check_button_settings_hide_hard_links.clone();
buttons_search_clone.connect_clicked(move |_| {
let included_directories = get_path_buf_from_vector_of_strings(get_string_from_list_store(&tree_view_included_directories));
@ -97,6 +98,7 @@ pub fn connect_button_search(
let recursive_search = check_button_recursive.get_active();
let excluded_items = entry_excluded_items.get_text().as_str().to_string().split(',').map(|e| e.to_string()).collect::<Vec<String>>();
let allowed_extensions = entry_allowed_extensions.get_text().as_str().to_string();
let hide_hard_links = check_button_settings_hide_hard_links.get_active();
let show_dialog = Arc::new(AtomicBool::new(true));
@ -164,6 +166,7 @@ pub fn connect_button_search(
df.set_minimal_file_size(minimal_file_size);
df.set_check_method(check_method);
df.set_hash_type(hash_type);
df.set_ignore_hard_links(hide_hard_links);
df.find_duplicates(Some(&stop_receiver), Some(&futures_sender_duplicate_files));
let _ = glib_stop_sender.send(Message::Duplicates(df));
});

View file

@ -54,7 +54,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
match msg {
Message::Duplicates(df) => {
if df.get_stopped_search() {
entry_info.set_text("Searching for duplicated was stopped by user");
entry_info.set_text("Searching for duplicates was stopped by user");
} else {
let information = df.get_information();
let text_messages = df.get_text_messages();
@ -426,7 +426,7 @@ pub fn connect_compute_results(gui_data: &GuiData, glib_stop_receiver: Receiver<
}
Message::SimilarImages(sf) => {
if sf.get_stopped_search() {
entry_info.set_text("Searching for duplicated was stopped by user");
entry_info.set_text("Searching for similar images was stopped by user");
} else {
//let information = sf.get_information();
let text_messages = sf.get_text_messages();

View file

@ -3,7 +3,7 @@ use crate::gui_data::GuiData;
use gtk::prelude::*;
pub fn connect_hide_text_view_errors(gui_data: &GuiData) {
let check_button_settings_show_text_view = gui_data.upper_notebook.check_button_settings_show_text_view.clone();
let check_button_settings_show_text_view = gui_data.settings.check_button_settings_show_text_view.clone();
let buttons_show_errors = gui_data.bottom_buttons.buttons_show_errors.clone();
let scrolled_window_errors = gui_data.scrolled_window_errors.clone();

View file

@ -4,10 +4,32 @@ use crate::saving_loading::{load_configuration, reset_configuration, save_config
use gtk::prelude::*;
pub fn connect_settings(gui_data: &GuiData) {
// Connect button settings
{
let button_settings = gui_data.header.button_settings.clone();
let window_main = gui_data.window_main.clone();
let window_settings = gui_data.settings.window_settings.clone();
button_settings.connect_clicked(move |_| {
window_main.set_sensitive(false);
window_settings.show();
});
let window_main = gui_data.window_main.clone();
let window_settings = gui_data.settings.window_settings.clone();
window_settings.hide_on_delete();
window_settings.connect_delete_event(move |window, _y| {
window.hide();
window_main.set_sensitive(true);
gtk::Inhibit(true)
});
}
// Connect save configuration button
{
let gui_data = gui_data.clone();
let button_settings_save_configuration = gui_data.upper_notebook.button_settings_save_configuration.clone();
let button_settings_save_configuration = gui_data.settings.button_settings_save_configuration.clone();
button_settings_save_configuration.connect_clicked(move |_| {
save_configuration(&gui_data, true);
});
@ -15,7 +37,7 @@ pub fn connect_settings(gui_data: &GuiData) {
// Connect load configuration button
{
let gui_data = gui_data.clone();
let button_settings_load_configuration = gui_data.upper_notebook.button_settings_load_configuration.clone();
let button_settings_load_configuration = gui_data.settings.button_settings_load_configuration.clone();
button_settings_load_configuration.connect_clicked(move |_| {
load_configuration(&gui_data, true);
});
@ -23,7 +45,7 @@ pub fn connect_settings(gui_data: &GuiData) {
// Connect reset configuration button
{
let gui_data = gui_data.clone();
let button_settings_reset_configuration = gui_data.upper_notebook.button_settings_reset_configuration.clone();
let button_settings_reset_configuration = gui_data.settings.button_settings_reset_configuration.clone();
button_settings_reset_configuration.connect_clicked(move |_| {
reset_configuration(&gui_data, true);
});

View file

@ -3,9 +3,9 @@ use crate::gui_about::GUIAbout;
use crate::gui_bottom_buttons::GUIBottomButtons;
use crate::gui_header::GUIHeader;
use crate::gui_main_notebook::GUIMainNotebook;
use crate::gui_options::GUIOptions;
use crate::gui_popovers::GUIPopovers;
use crate::gui_progress_dialog::GUIProgressDialog;
use crate::gui_settings::GUISettings;
use crate::gui_upper_notepad::GUIUpperNotebook;
use crate::notebook_enums::*;
use crate::taskbar_progress::TaskbarProgress;
@ -41,7 +41,7 @@ pub struct GuiData {
pub bottom_buttons: GUIBottomButtons,
pub progress_window: GUIProgressDialog,
pub about: GUIAbout,
pub options: GUIOptions,
pub settings: GUISettings,
pub header: GUIHeader,
// Taskbar state
@ -93,9 +93,9 @@ impl GuiData {
let popovers = GUIPopovers::create_from_builder(&builder);
let bottom_buttons = GUIBottomButtons::create_from_builder(&builder);
let progress_window = GUIProgressDialog::create_from_builder(&builder);
let options = GUIOptions::create_from_builder(&builder);
let about = GUIAbout::create_from_builder(&builder);
let header = GUIHeader::create_from_builder(&builder);
let settings = GUISettings::create_from_builder(&builder);
////////////////////////////////////////////////////////////////////////////////////////////////
@ -165,7 +165,7 @@ impl GuiData {
bottom_buttons,
progress_window,
about,
options,
settings,
header,
taskbar_state,
shared_buttons,

View file

@ -1,10 +0,0 @@
#[derive(Clone)]
pub struct GUIOptions {}
impl GUIOptions {
pub fn create_from_builder(_builder: &gtk::Builder) -> Self {
// let notebook_main: gtk::Notebook = builder.get_object("notebook_main").unwrap();
Self {}
}
}

View file

@ -0,0 +1,59 @@
use gtk::prelude::*;
#[derive(Clone)]
pub struct GUISettings {
pub window_settings: gtk::Window,
// General
pub check_button_settings_save_at_exit: gtk::CheckButton,
pub check_button_settings_load_at_start: gtk::CheckButton,
pub check_button_settings_confirm_deletion: gtk::CheckButton,
pub check_button_settings_show_text_view: gtk::CheckButton,
// Duplicates
pub check_button_settings_hide_hard_links: gtk::CheckButton,
// Similar Images
pub check_button_settings_show_preview_similar_images: gtk::CheckButton,
// Buttons
pub button_settings_save_configuration: gtk::Button,
pub button_settings_load_configuration: gtk::Button,
pub button_settings_reset_configuration: gtk::Button,
}
impl GUISettings {
pub fn create_from_builder(builder: &gtk::Builder) -> Self {
let window_settings: gtk::Window = builder.get_object("window_settings").unwrap();
// General
let check_button_settings_save_at_exit: gtk::CheckButton = builder.get_object("check_button_settings_save_at_exit").unwrap();
let check_button_settings_load_at_start: gtk::CheckButton = builder.get_object("check_button_settings_load_at_start").unwrap();
let check_button_settings_confirm_deletion: gtk::CheckButton = builder.get_object("check_button_settings_confirm_deletion").unwrap();
let check_button_settings_show_text_view: gtk::CheckButton = builder.get_object("check_button_settings_show_text_view").unwrap();
// Duplicates
let check_button_settings_hide_hard_links: gtk::CheckButton = builder.get_object("check_button_settings_hide_hard_links").unwrap();
// Similar Images
let check_button_settings_show_preview_similar_images: gtk::CheckButton = builder.get_object("check_button_settings_show_preview_similar_images").unwrap();
// Saving/Loading/Resetting configuration
let button_settings_save_configuration: gtk::Button = builder.get_object("button_settings_save_configuration").unwrap();
let button_settings_load_configuration: gtk::Button = builder.get_object("button_settings_load_configuration").unwrap();
let button_settings_reset_configuration: gtk::Button = builder.get_object("button_settings_reset_configuration").unwrap();
Self {
window_settings,
check_button_settings_save_at_exit,
check_button_settings_load_at_start,
check_button_settings_confirm_deletion,
check_button_settings_show_text_view,
button_settings_save_configuration,
button_settings_load_configuration,
button_settings_reset_configuration,
check_button_settings_show_preview_similar_images,
check_button_settings_hide_hard_links,
}
}
}

View file

@ -14,17 +14,6 @@ pub struct GUIUpperNotebook {
pub entry_excluded_items: gtk::Entry,
pub entry_allowed_extensions: gtk::Entry,
//// Settings
pub check_button_settings_save_at_exit: gtk::CheckButton,
pub check_button_settings_load_at_start: gtk::CheckButton,
pub check_button_settings_confirm_deletion: gtk::CheckButton,
pub check_button_settings_show_preview_similar_images: gtk::CheckButton,
pub check_button_settings_show_text_view: gtk::CheckButton,
pub button_settings_save_configuration: gtk::Button,
pub button_settings_load_configuration: gtk::Button,
pub button_settings_reset_configuration: gtk::Button,
pub check_button_recursive: gtk::CheckButton,
pub buttons_manual_add_directory: gtk::Button,
@ -48,17 +37,6 @@ impl GUIUpperNotebook {
let entry_allowed_extensions: gtk::Entry = builder.get_object("entry_allowed_extensions").unwrap();
let entry_excluded_items: gtk::Entry = builder.get_object("entry_excluded_items").unwrap();
//// Settings
let check_button_settings_save_at_exit: gtk::CheckButton = builder.get_object("check_button_settings_save_at_exit").unwrap();
let check_button_settings_load_at_start: gtk::CheckButton = builder.get_object("check_button_settings_load_at_start").unwrap();
let check_button_settings_confirm_deletion: gtk::CheckButton = builder.get_object("check_button_settings_confirm_deletion").unwrap();
let check_button_settings_show_preview_similar_images: gtk::CheckButton = builder.get_object("check_button_settings_show_preview_similar_images").unwrap();
let check_button_settings_show_text_view: gtk::CheckButton = builder.get_object("check_button_settings_show_text_view").unwrap();
let button_settings_save_configuration: gtk::Button = builder.get_object("button_settings_save_configuration").unwrap();
let button_settings_load_configuration: gtk::Button = builder.get_object("button_settings_load_configuration").unwrap();
let button_settings_reset_configuration: gtk::Button = builder.get_object("button_settings_reset_configuration").unwrap();
let check_button_recursive: gtk::CheckButton = builder.get_object("check_button_recursive").unwrap();
let buttons_manual_add_directory: gtk::Button = builder.get_object("buttons_manual_add_directory").unwrap();
@ -76,14 +54,6 @@ impl GUIUpperNotebook {
tree_view_excluded_directories,
entry_excluded_items,
entry_allowed_extensions,
check_button_settings_save_at_exit,
check_button_settings_load_at_start,
check_button_settings_confirm_deletion,
check_button_settings_show_preview_similar_images,
check_button_settings_show_text_view,
button_settings_save_configuration,
button_settings_load_configuration,
button_settings_reset_configuration,
check_button_recursive,
buttons_manual_add_directory,
buttons_add_included_directory,

View file

@ -27,10 +27,6 @@ pub fn initialize_gui(gui_data: &mut GuiData) {
buttons_delete.hide();
buttons_select.hide();
buttons_symlink.hide();
// TODO Add Option window
let button_settings = gui_data.header.button_settings.clone();
button_settings.hide();
}
//// Initialize main scrolled view with notebook
@ -47,7 +43,7 @@ pub fn initialize_gui(gui_data: &mut GuiData) {
let scrolled_window_broken_files = gui_data.main_notebook.scrolled_window_broken_files.clone();
let image_preview_similar_images = gui_data.main_notebook.image_preview_similar_images.clone();
let check_button_settings_show_preview_similar_images = gui_data.upper_notebook.check_button_settings_show_preview_similar_images.clone();
let check_button_settings_show_preview_similar_images = gui_data.settings.check_button_settings_show_preview_similar_images.clone();
let text_view_errors = gui_data.text_view_errors.clone();
// Set Main Scrolled Window Treeviews
@ -243,7 +239,7 @@ pub fn initialize_gui(gui_data: &mut GuiData) {
let image_preview_similar_images = image_preview_similar_images_clone.clone();
let text_view_errors = gui_data.text_view_errors.clone();
let check_button_settings_show_preview_similar_images = gui_data.upper_notebook.check_button_settings_show_preview_similar_images.clone();
let check_button_settings_show_preview_similar_images = gui_data.settings.check_button_settings_show_preview_similar_images.clone();
let gui_data = gui_data.clone();
tree_view.connect_key_release_event(move |tree_view, e| {
if let Some(button_number) = e.get_keycode() {

View file

@ -23,9 +23,9 @@ mod gui_bottom_buttons;
mod gui_data;
mod gui_header;
mod gui_main_notebook;
mod gui_options;
mod gui_popovers;
mod gui_progress_dialog;
mod gui_settings;
mod gui_upper_notepad;
mod help_functions;
mod initialize_gui;

View file

@ -13,7 +13,7 @@ use std::{env, fs};
const SAVE_FILE_NAME: &str = "czkawka_gui_config.txt";
pub fn save_configuration(gui_data: &GuiData, manual_execution: bool) {
let check_button_settings_save_at_exit = gui_data.upper_notebook.check_button_settings_save_at_exit.clone();
let check_button_settings_save_at_exit = gui_data.settings.check_button_settings_save_at_exit.clone();
let text_view_errors = gui_data.text_view_errors.clone();
reset_text_view(&text_view_errors);
@ -89,28 +89,33 @@ pub fn save_configuration(gui_data: &GuiData, manual_execution: bool) {
//// Save at exit
data_to_save.push("--save_at_exit:".to_string());
let check_button_settings_save_at_exit = gui_data.upper_notebook.check_button_settings_save_at_exit.clone();
let check_button_settings_save_at_exit = gui_data.settings.check_button_settings_save_at_exit.clone();
data_to_save.push(check_button_settings_save_at_exit.get_active().to_string());
//// Load at start
data_to_save.push("--load_at_start:".to_string());
let check_button_settings_load_at_start = gui_data.upper_notebook.check_button_settings_load_at_start.clone();
let check_button_settings_load_at_start = gui_data.settings.check_button_settings_load_at_start.clone();
data_to_save.push(check_button_settings_load_at_start.get_active().to_string());
//// Confirm deletion of files
data_to_save.push("--confirm_deletion:".to_string());
let check_button_settings_confirm_deletion = gui_data.upper_notebook.check_button_settings_confirm_deletion.clone();
let check_button_settings_confirm_deletion = gui_data.settings.check_button_settings_confirm_deletion.clone();
data_to_save.push(check_button_settings_confirm_deletion.get_active().to_string());
//// Show image previews in similar images
data_to_save.push("--show_previews:".to_string());
let check_button_settings_show_preview_similar_images = gui_data.upper_notebook.check_button_settings_show_preview_similar_images.clone();
let check_button_settings_show_preview_similar_images = gui_data.settings.check_button_settings_show_preview_similar_images.clone();
data_to_save.push(check_button_settings_show_preview_similar_images.get_active().to_string());
//// Show bottom text panel with errors
data_to_save.push("--bottom_text_panel:".to_string());
let check_button_settings_show_text_view = gui_data.upper_notebook.check_button_settings_show_text_view.clone();
let check_button_settings_show_text_view = gui_data.settings.check_button_settings_show_text_view.clone();
data_to_save.push(check_button_settings_show_text_view.get_active().to_string());
//// Show bottom text panel with errors
data_to_save.push("--hide_hard_links:".to_string());
let check_button_settings_hide_hard_links = gui_data.settings.check_button_settings_hide_hard_links.clone();
data_to_save.push(check_button_settings_hide_hard_links.get_active().to_string());
}
// Creating/Opening config file
@ -158,6 +163,7 @@ enum TypeOfLoadedData {
ConfirmDeletion,
ShowPreviews,
BottomTextPanel,
HideHardLinks,
}
pub fn load_configuration(gui_data: &GuiData, manual_execution: bool) {
@ -200,6 +206,7 @@ pub fn load_configuration(gui_data: &GuiData, manual_execution: bool) {
let mut confirm_deletion: bool = true;
let mut show_previews: bool = true;
let mut bottom_text_panel: bool = true;
let mut hide_hard_links: bool = true;
let mut current_type = TypeOfLoadedData::None;
for (line_number, line) in loaded_data.replace("\r\n", "\n").split('\n').enumerate() {
@ -225,6 +232,8 @@ pub fn load_configuration(gui_data: &GuiData, manual_execution: bool) {
current_type = TypeOfLoadedData::ShowPreviews;
} else if line.starts_with("--bottom_text_panel") {
current_type = TypeOfLoadedData::BottomTextPanel;
} else if line.starts_with("--hide_hard_links") {
current_type = TypeOfLoadedData::HideHardLinks;
} else if line.starts_with("--") {
current_type = TypeOfLoadedData::None;
add_text_to_text_view(
@ -316,6 +325,19 @@ pub fn load_configuration(gui_data: &GuiData, manual_execution: bool) {
);
}
}
TypeOfLoadedData::HideHardLinks => {
let line = line.to_lowercase();
if line == "1" || line == "true" {
hide_hard_links = true;
} else if line == "0" || line == "false" {
hide_hard_links = false;
} else {
add_text_to_text_view(
&text_view_errors,
format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
);
}
}
}
}
}
@ -355,19 +377,20 @@ pub fn load_configuration(gui_data: &GuiData, manual_execution: bool) {
entry_allowed_extensions.set_text(allowed_extensions.iter().map(|e| e.to_string() + ",").collect::<String>().as_str());
//// Buttons
gui_data.upper_notebook.check_button_settings_load_at_start.set_active(loading_at_start);
gui_data.upper_notebook.check_button_settings_save_at_exit.set_active(saving_at_exit);
gui_data.upper_notebook.check_button_settings_confirm_deletion.set_active(confirm_deletion);
gui_data.upper_notebook.check_button_settings_show_preview_similar_images.set_active(show_previews);
gui_data.settings.check_button_settings_load_at_start.set_active(loading_at_start);
gui_data.settings.check_button_settings_save_at_exit.set_active(saving_at_exit);
gui_data.settings.check_button_settings_confirm_deletion.set_active(confirm_deletion);
gui_data.settings.check_button_settings_show_preview_similar_images.set_active(show_previews);
gui_data.upper_notebook.check_button_settings_show_text_view.set_active(bottom_text_panel);
gui_data.settings.check_button_settings_show_text_view.set_active(bottom_text_panel);
if !bottom_text_panel {
gui_data.text_view_errors.hide();
gui_data.scrolled_window_errors.hide();
} else {
gui_data.text_view_errors.show();
gui_data.scrolled_window_errors.show();
}
gui_data.settings.check_button_settings_hide_hard_links.set_active(hide_hard_links);
} else {
gui_data.upper_notebook.check_button_settings_load_at_start.set_active(false);
gui_data.settings.check_button_settings_load_at_start.set_active(false);
}
if manual_execution {
@ -440,11 +463,12 @@ pub fn reset_configuration(gui_data: &GuiData, manual_clearing: bool) {
// Set settings
{
gui_data.upper_notebook.check_button_settings_save_at_exit.set_active(true);
gui_data.upper_notebook.check_button_settings_load_at_start.set_active(true);
gui_data.upper_notebook.check_button_settings_confirm_deletion.set_active(true);
gui_data.upper_notebook.check_button_settings_show_preview_similar_images.set_active(true);
gui_data.upper_notebook.check_button_settings_show_text_view.set_active(true);
gui_data.settings.check_button_settings_save_at_exit.set_active(true);
gui_data.settings.check_button_settings_load_at_start.set_active(true);
gui_data.settings.check_button_settings_confirm_deletion.set_active(true);
gui_data.settings.check_button_settings_show_preview_similar_images.set_active(true);
gui_data.settings.check_button_settings_show_text_view.set_active(true);
gui_data.settings.check_button_settings_hide_hard_links.set_active(true);
}
if manual_clearing {
add_text_to_text_view(&text_view_errors, "Current configuration was cleared.");