folder chooser parent

This commit is contained in:
ochibani 2022-10-19 19:39:22 +02:00
parent 336e8e42c5
commit 71edab62f1
2 changed files with 40 additions and 44 deletions

60
Cargo.lock generated
View File

@ -82,9 +82,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.11.0"
version = "3.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
[[package]]
name = "cairo-rs"
@ -102,7 +102,7 @@ dependencies = [
[[package]]
name = "cairo-rs"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"bitflags",
"cairo-sys-rs 0.16.0",
@ -126,7 +126,7 @@ dependencies = [
[[package]]
name = "cairo-sys-rs"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"glib-sys 0.16.0",
"libc",
@ -193,9 +193,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cxx"
version = "1.0.78"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19f39818dcfc97d45b03953c1292efc4e80954e1583c4aa770bac1383e2310a4"
checksum = "3f83d0ebf42c6eafb8d7c52f7e5f2d3003b89c7aa4fd2b79229209459a849af8"
dependencies = [
"cc",
"cxxbridge-flags",
@ -205,9 +205,9 @@ dependencies = [
[[package]]
name = "cxx-build"
version = "1.0.78"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e580d70777c116df50c390d1211993f62d40302881e54d4b79727acb83d0199"
checksum = "07d050484b55975889284352b0ffc2ecbda25c0c55978017c132b29ba0818a86"
dependencies = [
"cc",
"codespan-reporting",
@ -220,15 +220,15 @@ dependencies = [
[[package]]
name = "cxxbridge-flags"
version = "1.0.78"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56a46460b88d1cec95112c8c363f0e2c39afdb237f60583b0b36343bf627ea9c"
checksum = "99d2199b00553eda8012dfec8d3b1c75fce747cf27c169a270b3b99e3448ab78"
[[package]]
name = "cxxbridge-macro"
version = "1.0.78"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "747b608fecf06b0d72d440f27acc99288207324b793be2c17991839f3d4995ea"
checksum = "dcb67a6de1f602736dd7eaead0080cf3435df806c61b24b13328db128c58868f"
dependencies = [
"proc-macro2",
"quote",
@ -400,7 +400,7 @@ dependencies = [
[[package]]
name = "gdk-pixbuf"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"bitflags",
"gdk-pixbuf-sys 0.16.0",
@ -438,7 +438,7 @@ dependencies = [
[[package]]
name = "gdk-pixbuf-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"gio-sys 0.16.0",
"glib-sys 0.16.0",
@ -483,7 +483,7 @@ dependencies = [
[[package]]
name = "gdk4"
version = "0.5.0"
source = "git+https://github.com/gtk-rs/gtk4-rs.git#8dfb3a93de747137cf213e077902c2d993796c15"
source = "git+https://github.com/gtk-rs/gtk4-rs.git#e8c4fafb3703b340c10fac044f7764d5f1ebb8c8"
dependencies = [
"bitflags",
"cairo-rs 0.16.0",
@ -515,7 +515,7 @@ dependencies = [
[[package]]
name = "gdk4-sys"
version = "0.5.0"
source = "git+https://github.com/gtk-rs/gtk4-rs.git#8dfb3a93de747137cf213e077902c2d993796c15"
source = "git+https://github.com/gtk-rs/gtk4-rs.git#e8c4fafb3703b340c10fac044f7764d5f1ebb8c8"
dependencies = [
"cairo-sys-rs 0.16.0",
"gdk-pixbuf-sys 0.16.0",
@ -600,7 +600,7 @@ dependencies = [
[[package]]
name = "gio"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"bitflags",
"futures-channel",
@ -645,7 +645,7 @@ dependencies = [
[[package]]
name = "gio-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"glib-sys 0.16.0",
"gobject-sys 0.16.0",
@ -696,7 +696,7 @@ dependencies = [
[[package]]
name = "glib"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"bitflags",
"futures-channel",
@ -748,7 +748,7 @@ dependencies = [
[[package]]
name = "glib-macros"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"anyhow",
"heck 0.4.0",
@ -782,7 +782,7 @@ dependencies = [
[[package]]
name = "glib-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"libc",
"system-deps 6.0.2",
@ -813,7 +813,7 @@ dependencies = [
[[package]]
name = "gobject-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"glib-sys 0.16.0",
"libc",
@ -990,9 +990,9 @@ dependencies = [
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fde6edd6cef363e9359ed3c98ba64590ba9eecba2293eb5a723ab32aee8926aa"
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
dependencies = [
"cxx",
"cxx-build",
@ -1024,9 +1024,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.134"
version = "0.2.135"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
[[package]]
name = "link-cplusplus"
@ -1163,7 +1163,7 @@ dependencies = [
[[package]]
name = "pango"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"bitflags",
"gio 0.16.0",
@ -1188,7 +1188,7 @@ dependencies = [
[[package]]
name = "pango-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#588a146fd86fd6adaa7e682505f3b65f036bd2bf"
source = "git+https://github.com/gtk-rs/gtk-rs-core#4908f00b33d09ecd85f0c7d7d5649bd64a640adf"
dependencies = [
"glib-sys 0.16.0",
"gobject-sys 0.16.0",
@ -1276,9 +1276,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.46"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [
"unicode-ident",
]

View File

@ -302,6 +302,7 @@ pub fn build_ui(application: &Application) {
Some("Select"),
Some("Cancel"),
);
folder_chooser_native.set_transient_for(Some(&main_window));
folder_chooser_native.set_modal(true);
let folder_chooser = Some(gio::File::for_uri(&config_management::get("default", "folder"))).unwrap();
let folder_chooser_name = folder_chooser.basename().unwrap();
@ -311,21 +312,16 @@ pub fn build_ui(application: &Application) {
// Show file chooser dialog
folder_chooser_button.connect_clicked(glib::clone!(@strong folder_chooser_native => move |_| {
folder_chooser_native.connect_response(glib::clone!(@strong folder_chooser_native, @strong folder_chooser_label, @strong folder_chooser_image => move |_, response| {
if response == gtk::ResponseType::Accept {
let folder_chooser = folder_chooser_native.file().unwrap();
let folder_chooser_name = folder_chooser.basename().unwrap();
folder_chooser_label.set_label(&folder_chooser_name.to_string_lossy());
let folder_chooser_icon = config_management::folder_icon(folder_chooser_name.to_str());
folder_chooser_image.set_icon_name(Some(folder_chooser_icon));
};
folder_chooser_native.destroy();
if response == gtk::ResponseType::Accept {
let folder_chooser = folder_chooser_native.file().unwrap();
let folder_chooser_name = folder_chooser.basename().unwrap();
folder_chooser_label.set_label(&folder_chooser_name.to_string_lossy());
let folder_chooser_icon = config_management::folder_icon(folder_chooser_name.to_str());
folder_chooser_image.set_icon_name(Some(folder_chooser_icon));
};
folder_chooser_native.destroy();
}));
folder_chooser_native.show();
folder_chooser_native.show();
}));
// --- connections