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

Add option to save file, store settings and load them #108

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 40 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ But the most important thing for me was to learn Rust and create a program usefu
## Features
- Written in memory safe Rust
- Amazingly fast - due using more or less advanced algorithms and multithreading support
- Free, Open Source without ads
- CLI frontend, very fast and powerful with rich help
- GUI GTK frontend - uses modern GTK 3 and looks similar to FSlint
- Light/Dark theme match the appearance of the system(Linux only)
Expand Down
5 changes: 5 additions & 0 deletions czkawka_gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ glib = "0.10.1"
humansize = "1"
chrono = "0.4"

# Used for sending stop signal across threads
crossbeam-channel = "0.4.4"

# To get informations about progress
futures = "0.3.8"

# For saving/loading config files to specific directories
directories-next = "2.0.0"

# For opening files
open = "1.4.0"

Expand Down
98 changes: 98 additions & 0 deletions czkawka_gui/czkawka.glade
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,104 @@ Author: Rafał Mikrut
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<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>
<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="expand">False</property>
Expand Down
3 changes: 1 addition & 2 deletions czkawka_gui/src/connect_notebook_tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ pub fn connect_notebook_tabs(gui_data: &GuiData) {
set_buttons(&mut *shared_buttons.borrow_mut().get_mut(page).unwrap(), &buttons_array, &buttons_names);
// Upper notebook
{
//let upper_notebooks_labels = [/*"general",*/"included_directories","excluded_directories","excluded_items","allowed_extensions"];
let mut hashmap: HashMap<&str, &str> = Default::default();
//hashmap.insert("notebook_upper_general","general");
hashmap.insert("notebook_upper_included_directories", "included_directories");
hashmap.insert("notebook_upper_excluded_directories", "excluded_directories");
hashmap.insert("notebook_upper_excluded_items", "excluded_items");
hashmap.insert("notebook_upper_allowed_extensions", "allowed_extensions");
hashmap.insert("notebook_upper_settings", "settings");

for tab in &notebook_upper_children_names {
let name = hashmap.get(tab.as_str()).unwrap().to_string();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate gtk;
use crate::gui_data::GuiData;
use gtk::prelude::*;

pub fn connect_upper_notebook(gui_data: &GuiData) {
pub fn connect_selection_of_directories(gui_data: &GuiData) {
// Add included directory
{
let scrolled_window_included_directories = gui_data.scrolled_window_included_directories.clone();
Expand Down
31 changes: 31 additions & 0 deletions czkawka_gui/src/connect_settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extern crate gtk;
use crate::gui_data::GuiData;
use crate::saving_loading::{load_configuration, reset_configuration, save_configuration};
use gtk::prelude::*;

pub fn connect_settings(gui_data: &GuiData) {
// Connect save configuration button
{
let gui_data = gui_data.clone();
let button_settings_save_configuration = gui_data.button_settings_save_configuration.clone();
button_settings_save_configuration.connect_clicked(move |_| {
save_configuration(&gui_data, true);
});
}
// Connect load configuration button
{
let gui_data = gui_data.clone();
let button_settings_load_configuration = gui_data.button_settings_load_configuration.clone();
button_settings_load_configuration.connect_clicked(move |_| {
load_configuration(&gui_data, true);
});
}
// Connect reset configuration button
{
let gui_data = gui_data.clone();
let button_settings_reset_configuration = gui_data.button_settings_reset_configuration.clone();
button_settings_reset_configuration.connect_clicked(move |_| {
reset_configuration(&gui_data, true);
});
}
}
26 changes: 24 additions & 2 deletions czkawka_gui/src/gui_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct GuiData {

// States
pub main_notebooks_labels: [String; 8],
pub upper_notebooks_labels: [String; 4],
pub upper_notebooks_labels: [String; 5],
pub buttons_labels: [String; 4],
// Buttons state
pub shared_buttons: Rc<RefCell<HashMap<String, HashMap<String, bool>>>>,
Expand Down Expand Up @@ -145,6 +145,14 @@ pub struct GuiData {
pub grid_progress_stages: gtk::Grid,

pub button_stop_in_dialog: gtk::Button,

//// Settings
pub check_button_settings_save_at_exit: gtk::CheckButton,
pub check_button_settings_load_at_start: gtk::CheckButton,

pub button_settings_save_configuration: gtk::Button,
pub button_settings_load_configuration: gtk::Button,
pub button_settings_reset_configuration: gtk::Button,
//// Threads

// Used for sending stop signal to thread
Expand Down Expand Up @@ -176,10 +184,11 @@ impl GuiData {
"same_music".to_string(),
];
let upper_notebooks_labels = [
/*"general",*/ "included_directories".to_string(),
"included_directories".to_string(),
"excluded_directories".to_string(),
"excluded_items".to_string(),
"allowed_extensions".to_string(),
"settings".to_string(),
];
let buttons_labels = ["search".to_string(), "select".to_string(), "delete".to_string(), "save".to_string()];

Expand Down Expand Up @@ -337,6 +346,14 @@ impl GuiData {

let button_stop_in_dialog: gtk::Button = builder.get_object("button_stop_in_dialog").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 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();

//// Threads
// Types of messages to send to main thread where gui can be draw.

Expand Down Expand Up @@ -426,6 +443,11 @@ impl GuiData {
label_stage,
grid_progress_stages,
button_stop_in_dialog,
check_button_settings_save_at_exit,
check_button_settings_load_at_start,
button_settings_save_configuration,
button_settings_load_configuration,
button_settings_reset_configuration,
stop_sender,
stop_receiver,
}
Expand Down
Loading