diff --git a/Cargo.lock b/Cargo.lock index a408740..930a7a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,6 +110,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "bitflags" version = "1.3.2" @@ -254,6 +260,16 @@ dependencies = [ "crossbeam-utils 0.8.20", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -377,6 +393,15 @@ dependencies = [ "shared_child", ] +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -428,6 +453,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + [[package]] name = "field-offset" version = "0.3.6" @@ -444,6 +475,30 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -937,6 +992,25 @@ dependencies = [ "system-deps 7.0.1", ] +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes 1.6.0", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -970,6 +1044,77 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes 1.6.0", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes 1.6.0", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +dependencies = [ + "bytes 1.6.0", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes 1.6.0", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -993,6 +1138,16 @@ dependencies = [ "cc", ] +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "ignore" version = "0.4.22" @@ -1038,6 +1193,12 @@ dependencies = [ "libc", ] +[[package]] +name = "ipnet" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" + [[package]] name = "itoa" version = "1.0.11" @@ -1207,6 +1368,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "miniz_oxide" version = "0.7.4" @@ -1269,6 +1436,23 @@ dependencies = [ "ws2_32-sys", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "net2" version = "0.2.39" @@ -1323,6 +1507,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_pipe" version = "1.2.1" @@ -1418,6 +1646,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + [[package]] name = "pikman-update-manager" version = "0.1.0" @@ -1436,6 +1670,7 @@ dependencies = [ "lock_api 0.4.12", "pretty-bytes", "regex", + "reqwest", "rust-apt", "rust-i18n", "serde", @@ -1567,6 +1802,46 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64", + "bytes 1.6.0", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "rowan" version = "0.15.16" @@ -1684,6 +1959,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -1705,6 +1989,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1717,6 +2010,29 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.9.0" @@ -1778,6 +2094,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_yaml" version = "0.8.26" @@ -1871,6 +2199,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "synstructure" version = "0.12.6" @@ -1883,6 +2217,27 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -1915,6 +2270,19 @@ version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" +[[package]] +name = "tempfile" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +dependencies = [ + "cfg-if 1.0.0", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "termcolor" version = "1.4.1" @@ -1960,6 +2328,21 @@ dependencies = [ "syn 2.0.70", ] +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.38.0" @@ -2022,6 +2405,16 @@ dependencies = [ "syn 2.0.70", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-reactor" version = "0.1.12" @@ -2069,6 +2462,19 @@ dependencies = [ "tokio-reactor", ] +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes 1.6.0", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.7.8" @@ -2139,6 +2545,31 @@ dependencies = [ "winnow 0.6.13", ] +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + [[package]] name = "triomphe" version = "0.1.13" @@ -2150,12 +2581,33 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-width" version = "0.1.13" @@ -2168,6 +2620,23 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" version = "0.2.0" @@ -2190,6 +2659,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2221,6 +2699,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.92" @@ -2250,6 +2740,16 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.2.8" @@ -2468,6 +2968,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if 1.0.0", + "windows-sys 0.48.0", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index d145010..53a5a1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,4 +41,5 @@ lock_api = "0.4.2" libflatpak = { version = "0.5.0", package = "libflatpak", features = ["v1_11_1"] } regex = "1.10.6" duct = "0.13.7" +reqwest = { version = "0.11", features = ["blocking"] } diff --git a/locales/en_US.json b/locales/en_US.json index 1948fea..348351b 100644 --- a/locales/en_US.json +++ b/locales/en_US.json @@ -125,5 +125,20 @@ "unofficial_source_add_is_legacy_source_label_label": "Is A Source Repository", "apt_src_create_error_dialog_heading": "Could Not Save Changes: Error", "apt_src_create_error_dialog_ok_label": "OK", - "system_mirror_save_button_tooltip_text": "Save Changes" + "flatpak_manage_page_title": "Flatpak Settings", + "system_mirror_save_button_tooltip_text": "Save Changes", + "flatpak_remotes_columnview_col0_title": "Remote Title", + "flatpak_remotes_columnview_col1_title": "Remote URL", + "flatpak_remotes_columnview_col2_title": "Remote Installation Type", + "flatpak_remotes_label": "Flatpak Remotes", + "flatpak_remotes_label1_label": "These Remotes Are for Software Provided via Flatpak. They May Present a Security Risk. Only Add Remotes That You Trust.", + "flatpak_remotes_columnview_system": "System", + "flatpak_remotes_columnview_user": "User", + "flatpak_remote_add_dialog_heading": "Add Flatpak Remote from URL", + "flatpak_remote_add_dialog_add_label": "Add Remote", + "flatpak_remote_add_dialog_cancel_label": "Cancel", + "flatpak_remote_add_error_dialog_heading": "Flatpak Remote Changes Failed Error:", + "flatpak_remote_add_error_dialog_ok_label": "OK", + "flatpak_remote_add_name_prefrencesgroup_title": "Remote Name", + "flatpak_remote_add_url_prefrencesgroup_title": "Remote Ref URL (flatpakrepo)" } \ No newline at end of file diff --git a/src/bin/gui/build_ui/mod.rs b/src/bin/gui/build_ui/mod.rs index 487abdd..1244cc1 100644 --- a/src/bin/gui/build_ui/mod.rs +++ b/src/bin/gui/build_ui/mod.rs @@ -1,4 +1,5 @@ use crate::apt_manage_page::apt_manage_page; +use crate::flatpak_manage_page::flatpak_manage_page; use crate::apt_update_page; use crate::config::{APP_GITHUB, APP_ICON, APP_ID, VERSION}; use crate::flatpak_update_page; @@ -310,7 +311,7 @@ pub fn build_ui(app: &Application) { } window_adw_stack.add_titled( - &apt_manage_page(window, &apt_retry_signal_action), + &apt_manage_page(window.clone(), &apt_retry_signal_action), Some("apt_manage_page"), &t!("apt_manage_page_title"), ); @@ -319,6 +320,17 @@ pub fn build_ui(app: &Application) { add_content_button.clone()(false, "apt_manage_page".to_string(), t!("apt_manage_page_title").to_string()); } + window_adw_stack.add_titled( + &flatpak_manage_page(window, &flatpak_retry_signal_action), + Some("flatpak_manage_page"), + &t!("flatpak_manage_page_title"), + ); + + { + add_content_button.clone()(false, "flatpak_manage_page".to_string(), t!("flatpak_manage_page_title").to_string()); + } + + // Refresh button refresh_button.connect_clicked(clone!( @@ -331,7 +343,9 @@ pub fn build_ui(app: &Application) { move |_| { match window_adw_stack.visible_child_name().unwrap().as_str() { "apt_update_page" => apt_retry_signal_action.activate(None), + "apt_manage_page" => apt_retry_signal_action.activate(None), "flatpak_update_page" => flatpak_retry_signal_action.activate(None), + "flatpak_manage_page" => flatpak_retry_signal_action.activate(None), _ => {} } } diff --git a/src/bin/gui/flatpak_manage_page/add_dialog.rs b/src/bin/gui/flatpak_manage_page/add_dialog.rs index fd236d1..b72572a 100644 --- a/src/bin/gui/flatpak_manage_page/add_dialog.rs +++ b/src/bin/gui/flatpak_manage_page/add_dialog.rs @@ -2,7 +2,8 @@ use crate::apt_package_row::AptPackageRow; use adw::gio::SimpleAction; use adw::prelude::*; use apt_deb822_tools::Deb822Repository; -use regex::Regex; +use libflatpak::builders::RemoteRefBuilder; +use regex::{bytes, Regex}; use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject}; use gtk::*; use std::cell::Ref; @@ -16,196 +17,126 @@ use std::process::Command; use std::rc::Rc; use std::thread; use tokio::runtime::Runtime; +use libflatpak::prelude::*; +use libflatpak::InstalledRef; pub fn add_dialog_fn( window: adw::ApplicationWindow, reload_action: &gio::SimpleAction ) { - let unofficial_source_add_dialog_child_box = Box::builder() + let flatpak_remote_add_dialog_child_box = Box::builder() .hexpand(true) .orientation(Orientation::Vertical) .build(); - let unofficial_source_add_name_entry = gtk::Entry::builder() - .placeholder_text("WineHQ Debian") + let flatpak_remote_add_name_entry = gtk::Entry::builder() + .placeholder_text("Flathub") .build(); - let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_name_prefrencesgroup_title")) + let flatpak_remote_add_name_prefrencesgroup = adw::PreferencesGroup::builder() + .title(t!("flatpak_remote_add_name_prefrencesgroup_title")) .build(); - unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry); + flatpak_remote_add_name_prefrencesgroup.add(&flatpak_remote_add_name_entry); - let unofficial_source_add_uri_entry = gtk::Entry::builder() - .placeholder_text("https://dl.winehq.org/wine-builds/debian") + let flatpak_remote_add_url_entry = gtk::Entry::builder() + .placeholder_text("https://dl.flathub.org/repo/flathub.flatpakrepo") .build(); - let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_uri_prefrencesgroup_title")) + let flatpak_remote_add_url_prefrencesgroup = adw::PreferencesGroup::builder() + .title(t!("flatpak_remote_add_url_prefrencesgroup_title")) .build(); - unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry); + flatpak_remote_add_url_prefrencesgroup.add(&flatpak_remote_add_url_entry); - let unofficial_source_add_suites_entry = gtk::Entry::builder() - .placeholder_text("trixie bookworm sid") - .build(); - - let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_suites_prefrencesgroup_title")) - .build(); - - unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry); - - let unofficial_source_add_components_entry = gtk::Entry::builder() - .placeholder_text("main proprietary") - .build(); - - let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_components_prefrencesgroup_title")) - .build(); - - unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry); - - let unofficial_source_add_signed_entry = gtk::Entry::builder() - .sensitive(false) - .build(); - - let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_signed_prefrencesgroup_title")) - .build(); - - unofficial_source_add_signed_prefrencesgroup.add(&unofficial_source_add_signed_entry); - - let unofficial_source_add_archs_entry = gtk::Entry::builder() - .placeholder_text("amd64 arm64 i386") - .build(); - - let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_archs_prefrencesgroup_title")) - .build(); - - unofficial_source_add_archs_prefrencesgroup.add(&unofficial_source_add_archs_entry); - - let unofficial_source_add_box2 = gtk::Box::builder() + let flatpak_remote_add_box2 = gtk::Box::builder() .margin_top(10) .orientation(Orientation::Horizontal) .hexpand(true) .spacing(5) .build(); - let unofficial_source_add_is_source_label = gtk::Label::builder() - .label(t!("unofficial_source_add_is_source_label_label")) - .halign(Align::Start) + let flatpak_remote_user_togglebutton = gtk::ToggleButton::builder() .valign(Align::Center) - .build(); - - let unofficial_source_add_is_source_switch = gtk::Switch::builder() - .halign(Align::Start) - .valign(Align::Center) - .build(); - - let unofficial_source_signed_keyring_checkbutton = gtk::CheckButton::builder() - .halign(Align::Start) - .valign(Align::Center) - .label(t!("unofficial_source_signed_keyring_checkbutton_label")) + .hexpand(true) + .label(t!("flatpak_remotes_columnview_user")) .active(true) .build(); - let unofficial_source_signed_file_checkbutton = gtk::CheckButton::builder() - .halign(Align::Start) + let flatpak_remote_system_togglebutton = gtk::ToggleButton::builder() .valign(Align::Center) - .label(t!("unofficial_source_signed_file_checkbutton_label")) - .group(&unofficial_source_signed_keyring_checkbutton) - .build(); - - let unofficial_source_signed_url_checkbutton = gtk::CheckButton::builder() - .halign(Align::Start) - .valign(Align::Center) - .label(t!("unofficial_source_signed_url_checkbutton_label")) - .group(&unofficial_source_signed_keyring_checkbutton) + .hexpand(true) + .label(t!("flatpak_remotes_columnview_system")) + .group(&flatpak_remote_user_togglebutton) .build(); // - let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder() - .child(&unofficial_source_add_dialog_child_box) + let flatpak_remote_add_dialog_child_clamp = adw::Clamp::builder() + .child(&flatpak_remote_add_dialog_child_box) .maximum_size(500) .build(); - let unofficial_source_add_viewport = gtk::ScrolledWindow::builder() + let flatpak_remote_add_viewport = gtk::ScrolledWindow::builder() .hexpand(true) .vexpand(true) - .child(&unofficial_source_add_dialog_child_clamp) + .child(&flatpak_remote_add_dialog_child_clamp) .hscrollbar_policy(PolicyType::Never) .build(); - let unofficial_source_add_dialog = adw::MessageDialog::builder() + let flatpak_remote_add_dialog = adw::MessageDialog::builder() .transient_for(&window) - .extra_child(&unofficial_source_add_viewport) - .heading(t!("unofficial_source_add_dialog_heading")) + .extra_child(&flatpak_remote_add_viewport) + .heading(t!("flatpak_remote_add_dialog_heading")) .width_request(700) - .height_request(500) + .height_request(400) .build(); - unofficial_source_add_dialog.add_response( - "unofficial_source_add_dialog_add", - &t!("unofficial_source_add_dialog_add_label").to_string(), + flatpak_remote_add_dialog.add_response( + "flatpak_remote_add_dialog_add", + &t!("flatpak_remote_add_dialog_add_label").to_string(), ); - unofficial_source_add_dialog.add_response( - "unofficial_source_add_dialog_cancel", - &t!("unofficial_source_add_dialog_cancel_label").to_string(), + flatpak_remote_add_dialog.add_response( + "flatpak_remote_add_dialog_cancel", + &t!("flatpak_remote_add_dialog_cancel_label").to_string(), ); - unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false); + flatpak_remote_add_dialog.set_response_enabled("flatpak_remote_add_dialog_add", false); - unofficial_source_add_dialog.set_response_appearance( - "unofficial_source_add_dialog_cancel", + flatpak_remote_add_dialog.set_response_appearance( + "flatpak_remote_add_dialog_cancel", adw::ResponseAppearance::Destructive, ); - unofficial_source_add_dialog.set_response_appearance( - "unofficial_source_add_dialog_add", + flatpak_remote_add_dialog.set_response_appearance( + "flatpak_remote_add_dialog_add", adw::ResponseAppearance::Suggested, ); // - let unofficial_source_add_dialog_clone0 = unofficial_source_add_dialog.clone(); - let unofficial_source_add_name_entry_clone0 = unofficial_source_add_name_entry.clone(); - let unofficial_source_add_uri_entry_clone0 = unofficial_source_add_uri_entry.clone(); - let unofficial_source_add_suites_entry_clone0 = unofficial_source_add_suites_entry.clone(); - let unofficial_source_add_components_entry_clone0 = unofficial_source_add_components_entry.clone(); - let unofficial_source_add_signed_entry_clone0 = unofficial_source_add_signed_entry.clone(); - let unofficial_source_signed_keyring_checkbutton_clone0 = unofficial_source_signed_keyring_checkbutton.clone(); + let flatpak_remote_add_dialog_clone0 = flatpak_remote_add_dialog.clone(); + let flatpak_remote_add_name_entry_clone0 = flatpak_remote_add_name_entry.clone(); + let flatpak_remote_add_url_entry_clone0 = flatpak_remote_add_url_entry.clone(); + let add_button_update_state = move || { if - !unofficial_source_add_name_entry_clone0.text().is_empty() && - !unofficial_source_add_uri_entry_clone0.text().is_empty() && - !unofficial_source_add_suites_entry_clone0.text().is_empty() && - !unofficial_source_add_components_entry_clone0.text().is_empty() + !flatpak_remote_add_name_entry_clone0.text().is_empty() && + !flatpak_remote_add_url_entry_clone0.text().is_empty() { - if unofficial_source_signed_keyring_checkbutton_clone0.is_active() { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true); - } else if !unofficial_source_add_signed_entry_clone0.text().is_empty() { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true); - } else { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false); - } + flatpak_remote_add_dialog_clone0.set_response_enabled("flatpak_remote_add_dialog_add", true); } else { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false); + flatpak_remote_add_dialog_clone0.set_response_enabled("flatpak_remote_add_dialog_add", false); } }; // for entry in [ - &unofficial_source_add_name_entry, - &unofficial_source_add_uri_entry, - &unofficial_source_add_suites_entry, - &unofficial_source_add_components_entry, - &unofficial_source_add_signed_entry, + &flatpak_remote_add_name_entry, + &flatpak_remote_add_url_entry, ] { entry.connect_text_notify(clone!( #[strong] @@ -219,177 +150,70 @@ pub fn add_dialog_fn( } // - - unofficial_source_signed_keyring_checkbutton.connect_toggled(clone!( - #[weak] - unofficial_source_add_signed_entry, - #[strong] - add_button_update_state, - move |checkbutton| - { - if checkbutton.is_active() { - unofficial_source_add_signed_entry.set_sensitive(false); - unofficial_source_add_signed_entry.set_placeholder_text(Some("")); - add_button_update_state(); - } - } - ) - ); - - unofficial_source_signed_file_checkbutton.connect_toggled(clone!( - #[weak] - unofficial_source_add_signed_entry, - #[strong] - add_button_update_state, - move |checkbutton| - { - if checkbutton.is_active() { - unofficial_source_add_signed_entry.set_sensitive(true); - unofficial_source_add_signed_entry.set_placeholder_text(Some("/etc/apt/keyrings/winehq-archive.key")); - add_button_update_state(); - } - } - ) - ); - - unofficial_source_signed_url_checkbutton.connect_toggled(clone!( - #[weak] - unofficial_source_add_signed_entry, - #[strong] - add_button_update_state, - move |checkbutton| - { - if checkbutton.is_active() { - unofficial_source_add_signed_entry.set_sensitive(true); - unofficial_source_add_signed_entry.set_placeholder_text(Some("https://dl.winehq.org/wine-builds/winehq.key")); - add_button_update_state(); - } - } - ) - ); - unofficial_source_add_box2.append(&unofficial_source_add_is_source_label); - unofficial_source_add_box2.append(&unofficial_source_add_is_source_switch); - unofficial_source_add_box2.append(&unofficial_source_signed_keyring_checkbutton); - unofficial_source_add_box2.append(&unofficial_source_signed_file_checkbutton); - unofficial_source_add_box2.append(&unofficial_source_signed_url_checkbutton); + flatpak_remote_add_box2.append(&flatpak_remote_user_togglebutton); + flatpak_remote_add_box2.append(&flatpak_remote_system_togglebutton); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_name_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_uri_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_suites_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_components_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_archs_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_box2); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup); + flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_name_prefrencesgroup); + flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_url_prefrencesgroup); + flatpak_remote_add_dialog_child_box.append(&flatpak_remote_add_box2); let reload_action_clone0 = reload_action.clone(); - unofficial_source_add_dialog.clone() + flatpak_remote_add_dialog.clone() .choose(None::<&gio::Cancellable>, move |choice| { match choice.as_str() { - "unofficial_source_add_dialog_add" => { - let non_alphanum_regex = Regex::new(r"[^a-zA-Z0-9]").unwrap(); - let sign_method = if unofficial_source_signed_file_checkbutton.is_active() { - 1 - } else if unofficial_source_signed_url_checkbutton.is_active() { - 2 - } else { - 0 + "flatpak_remote_add_dialog_add" => { + let cancellable_no = libflatpak::gio::Cancellable::NONE; + + let flatpak_installation = match flatpak_remote_system_togglebutton.is_active() { + true => libflatpak::Installation::new_system(cancellable_no).unwrap(), + false => libflatpak::Installation::new_user(cancellable_no).unwrap(), }; - let repo_file_name = non_alphanum_regex.replace_all(unofficial_source_add_name_entry.text().as_str(), "_").to_string().to_lowercase(); - let new_repo = Deb822Repository { - repolib_name: Some(unofficial_source_add_name_entry.text().to_string()), - filepath: format!("/etc/apt/sources.list.d/{}.source", repo_file_name), - uris: Some(unofficial_source_add_uri_entry.text().to_string()), - types: if unofficial_source_add_is_source_switch.is_active() { - Some("deb deb-src".to_string()) - } else { - Some("deb".to_string()) - }, - suites: Some(unofficial_source_add_suites_entry.text().to_string()), - components: Some(unofficial_source_add_components_entry.text().to_string()), - architectures: if unofficial_source_add_archs_entry.text().is_empty() { - None - } else { - Some(unofficial_source_add_archs_entry.text().to_string()) - }, - signed_by: match sign_method { - 1 => Some(unofficial_source_add_signed_entry.text().to_string()), - 2 => Some(format!("/etc/apt/keyrings/{}.gpg.key", repo_file_name)), - _ => None - }, - ..Default::default() - }; - if sign_method == 2 { - match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) { - Ok(_) => { - match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move_with_wget", &repo_file_name, &unofficial_source_add_signed_entry.text().to_string(), &format!("/etc/apt/keyrings/{}.gpg.key", &repo_file_name)).run() { - Ok(_) => { - reload_action_clone0.activate(None); - } - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - reload_action_clone0.activate(None); - } - } - } - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - } + + match libflatpak::Remote::from_file(&flatpak_remote_add_name_entry.text(), &get_data_from_url(&flatpak_remote_add_url_entry.text()).unwrap()) { + Ok(remote) => { + match libflatpak::Installation::add_remote(&flatpak_installation, &remote, true, cancellable_no) { + Ok(_) => { + reload_action_clone0.activate(None); } - } else { - match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) { - Ok(_) => { - match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() { - Ok(_) => { - reload_action_clone0.activate(None); - } - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - reload_action_clone0.activate(None); - } + Err(e) => { + let flatpak_remote_add_error_dialog = adw::MessageDialog::builder() + .heading(t!("flatpak_remote_add_error_dialog_heading")) + .body(e.to_string()) + .build(); + flatpak_remote_add_error_dialog.add_response( + "flatpak_remote_add_error_dialog_ok", + &t!("flatpak_remote_add_error_dialog_ok_label").to_string(), + ); + flatpak_remote_add_error_dialog.present(); } } - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - reload_action_clone0.activate(None); - } + } + Err(e) => { + let flatpak_remote_add_error_dialog = adw::MessageDialog::builder() + .heading(t!("flatpak_remote_add_error_dialog_heading")) + .body(e.to_string()) + .build(); + flatpak_remote_add_error_dialog.add_response( + "flatpak_remote_add_error_dialog_ok", + &t!("flatpak_remote_add_error_dialog_ok_label").to_string(), + ); } } } _ => {} } }); +} + +fn get_data_from_url(url: &str) -> Result { + let data = reqwest::blocking::get(url)? + .text() + .unwrap(); + + let bytes = data.as_bytes(); + + let glib_bytes = libflatpak::glib::Bytes::from(bytes); + Ok(glib_bytes) } \ No newline at end of file diff --git a/src/bin/gui/flatpak_manage_page/deb822_edit_dialog.rs b/src/bin/gui/flatpak_manage_page/deb822_edit_dialog.rs deleted file mode 100644 index 79eeeae..0000000 --- a/src/bin/gui/flatpak_manage_page/deb822_edit_dialog.rs +++ /dev/null @@ -1,416 +0,0 @@ -use crate::apt_package_row::AptPackageRow; -use adw::gio::SimpleAction; -use adw::prelude::*; -use apt_deb822_tools::Deb822Repository; -use regex::Regex; -use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject}; -use gtk::*; -use std::cell::Ref; -use std::ops::Deref; -use pika_unixsocket_tools::pika_unixsocket_tools::*; -use rust_apt::cache::*; -use rust_apt::new_cache; -use rust_apt::records::RecordField; -use std::cell::RefCell; -use std::process::Command; -use std::rc::Rc; -use std::thread; -use tokio::runtime::Runtime; -use std::path::Path; - -pub fn deb822_edit_dialog_fn( - window: adw::ApplicationWindow, - deb822_repo: &Deb822Repository, - reload_action: &gio::SimpleAction, -) { - let repofile_path = Path::new(&deb822_repo.filepath); - let repo_file_name = repofile_path - .file_name() - .unwrap() - .to_str() - .unwrap() - .trim_end_matches(".sources") - .to_owned(); - - let unofficial_source_add_dialog_child_box = Box::builder() - .hexpand(true) - .orientation(Orientation::Vertical) - .build(); - - let unofficial_source_add_name_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_name_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_name_prefrencesgroup_title")) - .build(); - - unofficial_source_add_name_prefrencesgroup.add(&unofficial_source_add_name_entry); - - let unofficial_source_add_uri_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_uri_prefrencesgroup_title")) - .build(); - - unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry); - - let unofficial_source_add_suites_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_suites_prefrencesgroup_title")) - .build(); - - unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry); - - let unofficial_source_add_components_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_components_prefrencesgroup_title")) - .build(); - - unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry); - - let unofficial_source_add_signed_entry = gtk::Entry::builder() - .sensitive(false) - .build(); - - let unofficial_source_add_signed_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_signed_prefrencesgroup_title")) - .build(); - - unofficial_source_add_signed_prefrencesgroup.add(&unofficial_source_add_signed_entry); - - let unofficial_source_add_archs_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_archs_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_archs_prefrencesgroup_title")) - .build(); - - unofficial_source_add_archs_prefrencesgroup.add(&unofficial_source_add_archs_entry); - - let unofficial_source_add_box2 = gtk::Box::builder() - .margin_top(10) - .orientation(Orientation::Horizontal) - .hexpand(true) - .spacing(5) - .build(); - - let unofficial_source_add_is_source_label = gtk::Label::builder() - .label(t!("unofficial_source_add_is_source_label_label")) - .halign(Align::Start) - .valign(Align::Center) - .build(); - - - let unofficial_source_add_is_enabled_label = gtk::Label::builder() - .label(t!("unofficial_source_add_is_enabled_label_label")) - .halign(Align::Start) - .valign(Align::Center) - .build(); - - let unofficial_source_add_is_source_switch = gtk::Switch::builder() - .halign(Align::Start) - .valign(Align::Center) - .build(); - - let unofficial_source_add_is_enabled_switch = gtk::Switch::builder() - .halign(Align::Start) - .valign(Align::Center) - .build(); - - let unofficial_source_signed_keyring_checkbutton = gtk::CheckButton::builder() - .halign(Align::Start) - .valign(Align::Center) - .label(t!("unofficial_source_signed_keyring_checkbutton_label")) - .active(true) - .build(); - - let unofficial_source_signed_file_checkbutton = gtk::CheckButton::builder() - .halign(Align::Start) - .valign(Align::Center) - .label(t!("unofficial_source_signed_file_checkbutton_label")) - .group(&unofficial_source_signed_keyring_checkbutton) - .build(); - // - let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder() - .child(&unofficial_source_add_dialog_child_box) - .maximum_size(500) - .build(); - - let unofficial_source_add_viewport = gtk::ScrolledWindow::builder() - .hexpand(true) - .vexpand(true) - .child(&unofficial_source_add_dialog_child_clamp) - .hscrollbar_policy(PolicyType::Never) - .build(); - - let unofficial_source_add_dialog = adw::MessageDialog::builder() - .transient_for(&window) - .extra_child(&unofficial_source_add_viewport) - .heading(t!("unofficial_source_edit_dialog_heading").to_string() + " " + &repo_file_name) - .width_request(700) - .height_request(500) - .build(); - - unofficial_source_add_dialog.add_response( - "unofficial_source_edit_dialog_edit", - &t!("unofficial_source_edit_dialog_add_edit").to_string(), - ); - - unofficial_source_add_dialog.add_response( - "unofficial_source_add_dialog_cancel", - &t!("unofficial_source_add_dialog_cancel_label").to_string(), - ); - - unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false); - - unofficial_source_add_dialog.set_response_appearance( - "unofficial_source_add_dialog_cancel", - adw::ResponseAppearance::Destructive, - ); - - unofficial_source_add_dialog.set_response_appearance( - "unofficial_source_edit_dialog_edit", - adw::ResponseAppearance::Suggested, - ); - - // - - let unofficial_source_add_dialog_clone0 = unofficial_source_add_dialog.clone(); - let unofficial_source_add_name_entry_clone0 = unofficial_source_add_name_entry.clone(); - let unofficial_source_add_uri_entry_clone0 = unofficial_source_add_uri_entry.clone(); - let unofficial_source_add_suites_entry_clone0 = unofficial_source_add_suites_entry.clone(); - let unofficial_source_add_components_entry_clone0 = unofficial_source_add_components_entry.clone(); - let unofficial_source_add_signed_entry_clone0 = unofficial_source_add_signed_entry.clone(); - let unofficial_source_signed_keyring_checkbutton_clone0 = unofficial_source_signed_keyring_checkbutton.clone(); - - let add_button_update_state = move || { - if - !unofficial_source_add_name_entry_clone0.text().is_empty() && - !unofficial_source_add_uri_entry_clone0.text().is_empty() && - !unofficial_source_add_suites_entry_clone0.text().is_empty() && - !unofficial_source_add_components_entry_clone0.text().is_empty() - { - if unofficial_source_signed_keyring_checkbutton_clone0.is_active() { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true); - } else if !unofficial_source_add_signed_entry_clone0.text().is_empty() { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true); - } else { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false); - } - } else { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false); - } - }; - - // - - for entry in [ - &unofficial_source_add_name_entry, - &unofficial_source_add_uri_entry, - &unofficial_source_add_suites_entry, - &unofficial_source_add_components_entry, - &unofficial_source_add_signed_entry, - ] { - entry.connect_text_notify(clone!( - #[strong] - add_button_update_state, - move |_| - { - add_button_update_state(); - } - ) - ); - } - - // - - unofficial_source_signed_keyring_checkbutton.connect_toggled(clone!( - #[weak] - unofficial_source_add_signed_entry, - #[strong] - add_button_update_state, - move |checkbutton| - { - if checkbutton.is_active() { - unofficial_source_add_signed_entry.set_sensitive(false); - add_button_update_state(); - } - } - ) - ); - - unofficial_source_signed_file_checkbutton.connect_toggled(clone!( - #[weak] - unofficial_source_add_signed_entry, - #[strong] - add_button_update_state, - move |checkbutton| - { - if checkbutton.is_active() { - unofficial_source_add_signed_entry.set_sensitive(true); - add_button_update_state(); - } - } - ) - ); - - unofficial_source_add_box2.append(&unofficial_source_add_is_source_label); - unofficial_source_add_box2.append(&unofficial_source_add_is_source_switch); - unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_label); - unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_switch); - unofficial_source_add_box2.append(&unofficial_source_signed_keyring_checkbutton); - unofficial_source_add_box2.append(&unofficial_source_signed_file_checkbutton); - - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_name_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_uri_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_suites_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_components_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_archs_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_box2); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup); - - - // - - match &deb822_repo.repolib_name { - Some(t) => { - unofficial_source_add_name_entry.set_text(&t); - } - None => {} - } - match &deb822_repo.uris { - Some(t) => { - unofficial_source_add_uri_entry.set_text(&t); - } - None => {} - } - match &deb822_repo.suites { - Some(t) => { - unofficial_source_add_suites_entry.set_text(&t); - } - None => {} - } - match &deb822_repo.components { - Some(t) => { - unofficial_source_add_components_entry.set_text(&t); - } - None => {} - } - match &deb822_repo.signed_by { - Some(t) => { - unofficial_source_signed_file_checkbutton.set_active(true); - unofficial_source_add_signed_entry.set_text(&t); - } - None => { - unofficial_source_signed_keyring_checkbutton.set_active(true) - } - } - match &deb822_repo.architectures { - Some(t) => { - unofficial_source_add_archs_entry.set_text(&t); - } - None => {} - } - match &deb822_repo.enabled { - Some(t) => { - unofficial_source_add_is_enabled_switch.set_active(match t.to_lowercase().as_str() { - "yes" => true, - "true" => true, - "no" => false, - "false" => false, - _ => true, - }); - } - None => { - unofficial_source_add_is_enabled_switch.set_active(true); - } - } - - match &deb822_repo.types { - Some(t) => { - unofficial_source_add_is_source_switch.set_active(t.contains("deb-src")); - } - None => {} - } - - // - let deb822_repo_clone0 = deb822_repo.clone(); - - let reload_action_clone0 = reload_action.clone(); - - unofficial_source_add_dialog.clone() - .choose(None::<&gio::Cancellable>, move |choice| { - match choice.as_str() { - "unofficial_source_edit_dialog_edit" => { - let sign_method = if unofficial_source_signed_file_checkbutton.is_active() { - 1 - } else { - 0 - }; - let new_repo = Deb822Repository { - repolib_name: Some(unofficial_source_add_name_entry.text().to_string()), - filepath: format!("/etc/apt/sources.list.d/{}.source", repo_file_name), - uris: Some(unofficial_source_add_uri_entry.text().to_string()), - types: if unofficial_source_add_is_source_switch.is_active() { - Some("deb deb-src".to_string()) - } else { - Some("deb".to_string()) - }, - suites: Some(unofficial_source_add_suites_entry.text().to_string()), - components: Some(unofficial_source_add_components_entry.text().to_string()), - architectures: if unofficial_source_add_archs_entry.text().is_empty() { - None - } else { - Some(unofficial_source_add_archs_entry.text().to_string()) - }, - signed_by: match sign_method { - 1 => Some(unofficial_source_add_signed_entry.text().to_string()), - _ => None - }, - enabled: match unofficial_source_add_is_enabled_switch.is_active() { - true => Some("yes".to_string()), - false => Some("no".to_string()) - }, - ..deb822_repo_clone0 - }; - match Deb822Repository::write_to_file(new_repo.clone(), format!("/tmp/{}.sources", repo_file_name).into()) { - Ok(_) => { - match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() { - Ok(_) => {} - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - } - } - reload_action_clone0.activate(None); - } - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - reload_action_clone0.activate(None); - } - } - } - _ => {} - } - }); -} \ No newline at end of file diff --git a/src/bin/gui/flatpak_manage_page/legacy_edit_dialog.rs b/src/bin/gui/flatpak_manage_page/legacy_edit_dialog.rs deleted file mode 100644 index c69a9c3..0000000 --- a/src/bin/gui/flatpak_manage_page/legacy_edit_dialog.rs +++ /dev/null @@ -1,272 +0,0 @@ -use crate::apt_package_row::AptPackageRow; -use adw::gio::SimpleAction; -use adw::prelude::*; -use apt_legacy_tools::LegacyAptSource; -use regex::Regex; -use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject}; -use gtk::*; -use std::cell::Ref; -use std::ops::Deref; -use pika_unixsocket_tools::pika_unixsocket_tools::*; -use rust_apt::cache::*; -use rust_apt::new_cache; -use rust_apt::records::RecordField; -use std::cell::RefCell; -use std::process::Command; -use std::rc::Rc; -use std::thread; -use tokio::runtime::Runtime; -use std::path::Path; - -pub fn legacy_edit_dialog_fn( - window: adw::ApplicationWindow, - legacy_repo: &LegacyAptSource, - reload_action: &gio::SimpleAction, -) { - let repofile_path = Path::new(&legacy_repo.filepath); - let repo_file_name = repofile_path - .file_name() - .unwrap() - .to_str() - .unwrap() - .trim_end_matches(".list") - .to_owned(); - - let unofficial_source_add_dialog_child_box = Box::builder() - .hexpand(true) - .orientation(Orientation::Vertical) - .build(); - - let unofficial_source_add_uri_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_uri_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_uri_prefrencesgroup_title")) - .build(); - - unofficial_source_add_uri_prefrencesgroup.add(&unofficial_source_add_uri_entry); - - let unofficial_source_add_suites_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_suites_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_suites_prefrencesgroup_title")) - .build(); - - unofficial_source_add_suites_prefrencesgroup.add(&unofficial_source_add_suites_entry); - - let unofficial_source_add_components_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_components_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_components_prefrencesgroup_title")) - .build(); - - unofficial_source_add_components_prefrencesgroup.add(&unofficial_source_add_components_entry); - - let unofficial_source_add_legacy_options_entry = gtk::Entry::builder() - .build(); - - let unofficial_source_add_legacy_options_prefrencesgroup = adw::PreferencesGroup::builder() - .title(t!("unofficial_source_add_legacy_options_prefrencesgroup_title")) - .build(); - - unofficial_source_add_legacy_options_prefrencesgroup.add(&unofficial_source_add_legacy_options_entry); - - let unofficial_source_add_box2 = gtk::Box::builder() - .margin_top(10) - .orientation(Orientation::Horizontal) - .hexpand(true) - .spacing(5) - .build(); - - let unofficial_source_add_is_source_label = gtk::Label::builder() - .label(t!("unofficial_source_add_is_legacy_source_label_label")) - .halign(Align::Start) - .valign(Align::Center) - .build(); - - - let unofficial_source_add_is_enabled_label = gtk::Label::builder() - .label(t!("unofficial_source_add_is_enabled_label_label")) - .halign(Align::Start) - .valign(Align::Center) - .build(); - - let unofficial_source_add_is_source_switch = gtk::Switch::builder() - .halign(Align::Start) - .valign(Align::Center) - .build(); - - let unofficial_source_add_is_enabled_switch = gtk::Switch::builder() - .halign(Align::Start) - .valign(Align::Center) - .build(); - - // - let unofficial_source_add_dialog_child_clamp = adw::Clamp::builder() - .child(&unofficial_source_add_dialog_child_box) - .maximum_size(500) - .build(); - - let unofficial_source_add_viewport = gtk::ScrolledWindow::builder() - .hexpand(true) - .vexpand(true) - .child(&unofficial_source_add_dialog_child_clamp) - .hscrollbar_policy(PolicyType::Never) - .build(); - - let unofficial_source_add_dialog = adw::MessageDialog::builder() - .transient_for(&window) - .extra_child(&unofficial_source_add_viewport) - .heading(t!("unofficial_source_edit_dialog_heading").to_string() + " " + &repo_file_name) - .width_request(700) - .height_request(500) - .build(); - - unofficial_source_add_dialog.add_response( - "unofficial_source_edit_dialog_edit", - &t!("unofficial_source_edit_dialog_add_edit").to_string(), - ); - - unofficial_source_add_dialog.add_response( - "unofficial_source_add_dialog_cancel", - &t!("unofficial_source_add_dialog_cancel_label").to_string(), - ); - - unofficial_source_add_dialog.set_response_enabled("unofficial_source_add_dialog_add", false); - - unofficial_source_add_dialog.set_response_appearance( - "unofficial_source_add_dialog_cancel", - adw::ResponseAppearance::Destructive, - ); - - unofficial_source_add_dialog.set_response_appearance( - "unofficial_source_edit_dialog_edit", - adw::ResponseAppearance::Suggested, - ); - - // - - let unofficial_source_add_dialog_clone0 = unofficial_source_add_dialog.clone(); - let unofficial_source_add_uri_entry_clone0 = unofficial_source_add_uri_entry.clone(); - let unofficial_source_add_suites_entry_clone0 = unofficial_source_add_suites_entry.clone(); - let unofficial_source_add_components_entry_clone0 = unofficial_source_add_components_entry.clone(); - - let add_button_update_state = move || { - if - !unofficial_source_add_uri_entry_clone0.text().is_empty() && - !unofficial_source_add_suites_entry_clone0.text().is_empty() && - !unofficial_source_add_components_entry_clone0.text().is_empty() - { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", true); - } else { - unofficial_source_add_dialog_clone0.set_response_enabled("unofficial_source_add_dialog_add", false); - } - }; - - // - - for entry in [ - &unofficial_source_add_uri_entry, - &unofficial_source_add_suites_entry, - &unofficial_source_add_components_entry, - &unofficial_source_add_legacy_options_entry, - ] { - entry.connect_text_notify(clone!( - #[strong] - add_button_update_state, - move |_| - { - add_button_update_state(); - } - ) - ); - } - - // - - unofficial_source_add_box2.append(&unofficial_source_add_is_source_label); - unofficial_source_add_box2.append(&unofficial_source_add_is_source_switch); - unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_label); - unofficial_source_add_box2.append(&unofficial_source_add_is_enabled_switch); - - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_uri_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_suites_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_components_prefrencesgroup); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_box2); - unofficial_source_add_dialog_child_box.append(&unofficial_source_add_legacy_options_prefrencesgroup); - - - // - - unofficial_source_add_uri_entry.set_text(&legacy_repo.url); - unofficial_source_add_suites_entry.set_text(&legacy_repo.suite); - unofficial_source_add_components_entry.set_text(&legacy_repo.components); - match &legacy_repo.options { - Some(t) => { - unofficial_source_add_legacy_options_entry.set_text(&t); - } - None => {} - } - unofficial_source_add_is_enabled_switch.set_active(legacy_repo.enabled); - - unofficial_source_add_is_source_switch.set_active(legacy_repo.is_source); - - // - let legacy_repo_clone0 = legacy_repo.clone(); - - let reload_action_clone0 = reload_action.clone(); - - unofficial_source_add_dialog.clone() - .choose(None::<&gio::Cancellable>, move |choice| { - match choice.as_str() { - "unofficial_source_edit_dialog_edit" => { - let mut new_apt_legacy_vec = LegacyAptSource::get_legacy_sources().unwrap(); - new_apt_legacy_vec.retain(|x| x != &legacy_repo_clone0); - let new_repo = LegacyAptSource { - url: unofficial_source_add_uri_entry.text().to_string(), - is_source: unofficial_source_add_is_source_switch.is_active(), - suite: unofficial_source_add_suites_entry.text().to_string(), - components: unofficial_source_add_components_entry.text().to_string(), - options: Some(unofficial_source_add_legacy_options_entry.text().to_string()), - enabled: unofficial_source_add_is_enabled_switch.is_active(), - ..legacy_repo_clone0 - }; - new_apt_legacy_vec.push(new_repo.clone()); - match LegacyAptSource::save_to_file(new_repo, new_apt_legacy_vec, &format!("/tmp/{}.list", repo_file_name)) { - Ok(_) => { - match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "legacy_move", repo_file_name).run() { - Ok(_) => {} - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - } - } - reload_action_clone0.activate(None); - } - Err(e) => { - let apt_src_create_error_dialog = adw::MessageDialog::builder() - .heading(t!("apt_src_create_error_dialog_heading")) - .body(e.to_string()) - .build(); - apt_src_create_error_dialog.add_response( - "apt_src_create_error_dialog_ok", - &t!("apt_src_create_error_dialog_ok_label").to_string(), - ); - apt_src_create_error_dialog.present(); - reload_action_clone0.activate(None); - } - } - } - _ => {} - } - }); -} \ No newline at end of file diff --git a/src/bin/gui/flatpak_manage_page/mod.rs b/src/bin/gui/flatpak_manage_page/mod.rs index d26f4c4..cdf7366 100644 --- a/src/bin/gui/flatpak_manage_page/mod.rs +++ b/src/bin/gui/flatpak_manage_page/mod.rs @@ -3,7 +3,6 @@ use add_dialog::add_dialog_fn; use adw::gio::SimpleAction; use adw::prelude::*; use apt_deb822_tools::Deb822Repository; -use regex::Regex; use gtk::glib::{property::PropertyGet, clone, BoxedAnyObject}; use gtk::*; use std::cell::Ref; @@ -17,31 +16,25 @@ use std::process::Command; use std::rc::Rc; use std::thread; use tokio::runtime::Runtime; +use crate::flatpak_ref_row::FlatpakRefRow; +use adw::prelude::*; +use gtk::glib::*; +use gtk::*; +use libflatpak::prelude::*; +use libflatpak::InstalledRef; mod add_dialog; -mod deb822_edit_dialog; -mod legacy_edit_dialog; -enum AptSourceConfig { - Legacy(apt_legacy_tools::LegacyAptSource), - DEB822(apt_deb822_tools::Deb822Repository) +enum FlatpakRemote { + System(libflatpak::Remote), + User(libflatpak::Remote) } -pub fn apt_manage_page( +pub fn flatpak_manage_page( window: adw::ApplicationWindow, retry_signal_action: &SimpleAction, ) -> gtk::Box { - - let deb822_sources = Deb822Repository::get_deb822_sources().unwrap(); - - let system_source = deb822_sources.iter().filter(|x| { - match &x.repolib_id { - Some(t) => { - t == "system" - } - None => false - } - }).next().unwrap(); + let cancellable_no = libflatpak::gio::Cancellable::NONE; let main_box = Box::builder() .hexpand(true) @@ -51,8 +44,8 @@ pub fn apt_manage_page( // - let system_mirror_label0 = gtk::Label::builder() - .label(t!("system_mirror_label0_label")) + let flatpak_remotes_label0 = gtk::Label::builder() + .label(t!("flatpak_remotes_label")) .halign(gtk::Align::Start) .valign(gtk::Align::Start) .hexpand(true) @@ -61,10 +54,10 @@ pub fn apt_manage_page( .margin_end(15) .margin_bottom(5) .build(); - system_mirror_label0.add_css_class("heading"); + flatpak_remotes_label0.add_css_class("heading"); - let system_mirror_label1 = gtk::Label::builder() - .label(t!("system_mirror_label1_label")) + let flatpak_remotes_label1 = gtk::Label::builder() + .label(t!("flatpak_remotes_label1_label")) .halign(gtk::Align::Start) .valign(gtk::Align::Start) .hexpand(true) @@ -72,94 +65,60 @@ pub fn apt_manage_page( .margin_end(15) .build(); - let system_mirror_entry = gtk::Entry::builder() - .placeholder_text(system_source.repolib_default_mirror.as_deref().unwrap()) - .text(system_source.uris.as_deref().unwrap()) - .valign(gtk::Align::Start) - .margin_top(5) - .margin_bottom(5) - .margin_start(15) - .margin_end(15) - .build(); + let flatpak_remotes_selection_model_rc: Rc> = Rc::new(RefCell::default()); - // + let flatpak_remotes_selection_model_rc_clone0 = Rc::clone(&flatpak_remotes_selection_model_rc); - let unofficial_sources_label0 = gtk::Label::builder() - .label(t!("unofficial_sources_label")) - .halign(gtk::Align::Start) - .valign(gtk::Align::Start) - .hexpand(true) - .margin_top(15) - .margin_start(15) - .margin_end(15) - .margin_bottom(5) - .build(); - unofficial_sources_label0.add_css_class("heading"); + let flatpak_remotes_columnview_bin = adw::Bin::new(); - let unofficial_sources_label1 = gtk::Label::builder() - .label(t!("unofficial_sources_label1_label")) - .halign(gtk::Align::Start) - .valign(gtk::Align::Start) - .hexpand(true) - .margin_start(15) - .margin_end(15) - .build(); - - let unofficial_sources_selection_model_rc: Rc> = Rc::new(RefCell::default()); - - let unofficial_sources_selection_model_rc_clone0 = Rc::clone(&unofficial_sources_selection_model_rc); - - let unofficial_sources_columnview_bin = adw::Bin::new(); - - let unofficial_sources_columnview_bin_clone0 = unofficial_sources_columnview_bin.clone(); + let flatpak_remotes_columnview_bin_clone0 = flatpak_remotes_columnview_bin.clone(); retry_signal_action.connect_activate(clone!( #[weak] - unofficial_sources_columnview_bin_clone0, + flatpak_remotes_columnview_bin_clone0, + #[strong] + cancellable_no, move |_, _| { - let mut unofficial_deb822_sources = Deb822Repository::get_deb822_sources().unwrap(); - - unofficial_deb822_sources.retain(|x| { - match &x.repolib_id { - Some(t) => { - !(t == "system") - } - None => true - } - }); + let flatpak_system_installation = + libflatpak::Installation::new_system(cancellable_no).unwrap(); + let flatpak_user_installation = + libflatpak::Installation::new_user(cancellable_no).unwrap(); - let legacy_apt_repos = apt_legacy_tools::LegacyAptSource::get_legacy_sources(); + let system_remotes = match libflatpak::Installation::list_remotes(&flatpak_system_installation, cancellable_no) { + Ok(t) => t, + Err(_) => Vec::new() + }; + + let user_remotes = match libflatpak::Installation::list_remotes(&flatpak_user_installation, cancellable_no) { + Ok(t) => t, + Err(_) => Vec::new() + }; - let unofficial_sources_list_store = gio::ListStore::new::(); + let flatpak_remotes_list_store = gio::ListStore::new::(); - for deb822_source in unofficial_deb822_sources { - unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::DEB822(deb822_source))); + for remote in system_remotes { + flatpak_remotes_list_store.append(&BoxedAnyObject::new(FlatpakRemote::System(remote))); }; - match legacy_apt_repos { - Ok(vec) => { - for legacy_repo in vec { - unofficial_sources_list_store.append(&BoxedAnyObject::new(AptSourceConfig::Legacy(legacy_repo))); - }; - } - Err(_) => {} - } + for remote in user_remotes { + flatpak_remotes_list_store.append(&BoxedAnyObject::new(FlatpakRemote::User(remote))); + }; - let unofficial_sources_selection_model = SingleSelection::new(Some(unofficial_sources_list_store)); + let flatpak_remotes_selection_model = SingleSelection::new(Some(flatpak_remotes_list_store)); - (*unofficial_sources_selection_model_rc_clone0.borrow_mut() = unofficial_sources_selection_model.clone()); + (*flatpak_remotes_selection_model_rc_clone0.borrow_mut() = flatpak_remotes_selection_model.clone()); - let unofficial_sources_columnview = ColumnView::builder() + let flatpak_remotes_columnview = ColumnView::builder() .vexpand(true) - .model(&unofficial_sources_selection_model) + .model(&flatpak_remotes_selection_model) .build(); // - let unofficial_sources_columnview_factory0 = gtk::SignalListItemFactory::new(); + let flatpak_remotes_columnview_factory0 = gtk::SignalListItemFactory::new(); - unofficial_sources_columnview_factory0.connect_setup(move |_factory, item| { + flatpak_remotes_columnview_factory0.connect_setup(move |_factory, item| { let item = item.downcast_ref::().unwrap(); let row = Label::builder() .halign(Align::Start) @@ -167,54 +126,66 @@ pub fn apt_manage_page( item.set_child(Some(&row)); }); - unofficial_sources_columnview_factory0.connect_bind(move |_factory, item| { + flatpak_remotes_columnview_factory0.connect_bind(move |_factory, item| { let item: &ListItem = item.downcast_ref::().unwrap(); let child = item.child().and_downcast::