Use UUID as app id

This commit is contained in:
william 2023-09-10 16:14:44 -04:00
parent 8e0bf14cc8
commit 9bc67682ad
9 changed files with 178 additions and 82 deletions

187
Cargo.lock generated
View File

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.71" version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
@ -16,9 +16,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.3.3" version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]] [[package]]
name = "cairo-rs" name = "cairo-rs"
@ -47,18 +47,25 @@ dependencies = [
[[package]] [[package]]
name = "cfg-expr" name = "cfg-expr"
version = "0.15.3" version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "215c0072ecc28f92eeb0eea38ba63ddfcb65c2828c46311d646f1a3ff5f9841c" checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3"
dependencies = [ dependencies = [
"smallvec", "smallvec",
"target-lexicon", "target-lexicon",
] ]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "config-manager-client" name = "config-manager-client"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"f-uuid",
"glib-build-tools", "glib-build-tools",
"gtk4", "gtk4",
"libadwaita", "libadwaita",
@ -67,10 +74,26 @@ dependencies = [
] ]
[[package]] [[package]]
name = "equivalent" name = "deranged"
version = "1.0.0" version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "f-uuid"
version = "1.0.0"
source = "registry+https://gitea.fyloz.dev/william/_cargo-index.git"
checksum = "ba73c5b8fcda058d64a8ce4d89a37b1457cedf0a50759b601f55581c958533ec"
dependencies = [
"getrandom",
"serde",
]
[[package]] [[package]]
name = "field-offset" name = "field-offset"
@ -122,7 +145,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.22", "syn 2.0.31",
] ]
[[package]] [[package]]
@ -173,9 +196,9 @@ dependencies = [
[[package]] [[package]]
name = "gdk4" name = "gdk4"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8965ed5455cbfa1eb45c14a3b971cbacb43481913a3a5b9078b2ef0d9a01bd4b" checksum = "6982d9815ed6ac95b0467b189e81f29dea26d08a732926ec113e65744ed3f96c"
dependencies = [ dependencies = [
"cairo-rs", "cairo-rs",
"gdk-pixbuf", "gdk-pixbuf",
@ -188,9 +211,9 @@ dependencies = [
[[package]] [[package]]
name = "gdk4-sys" name = "gdk4-sys"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeffd4a7d68046c28666d817071bf025254aaed4df35099443f0c306ca6177f3" checksum = "dbab43f332a3cf1df9974da690b5bb0e26720ed09a228178ce52175372dcfef0"
dependencies = [ dependencies = [
"cairo-sys-rs", "cairo-sys-rs",
"gdk-pixbuf-sys", "gdk-pixbuf-sys",
@ -203,6 +226,17 @@ dependencies = [
"system-deps", "system-deps",
] ]
[[package]]
name = "getrandom"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]] [[package]]
name = "gio" name = "gio"
version = "0.18.1" version = "0.18.1"
@ -275,7 +309,7 @@ dependencies = [
"proc-macro-error", "proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.22", "syn 2.0.31",
] ]
[[package]] [[package]]
@ -324,9 +358,9 @@ dependencies = [
[[package]] [[package]]
name = "gsk4" name = "gsk4"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53b3b9e8090acb325d08cde84b30fc29b963a75fbac93160e9c5a30d2b335742" checksum = "cc25855255120f294d874acd6eaf4fbed7ce1cdc550e2d8415ea57fafbe816d5"
dependencies = [ dependencies = [
"cairo-rs", "cairo-rs",
"gdk4", "gdk4",
@ -339,9 +373,9 @@ dependencies = [
[[package]] [[package]]
name = "gsk4-sys" name = "gsk4-sys"
version = "0.7.0" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0770d1ede7189092748c4ef5b6921264eb945fd2318a58e8f59dc273000810f8" checksum = "e1ecf3a63bf1223d68f80f72cc896c4d8c80482fbce1c9a12c66d3de7290ee46"
dependencies = [ dependencies = [
"cairo-sys-rs", "cairo-sys-rs",
"gdk4-sys", "gdk4-sys",
@ -355,9 +389,9 @@ dependencies = [
[[package]] [[package]]
name = "gtk4" name = "gtk4"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0973f9b9ade10fc22403810b7283d47b533033715f2aaa36288cd3bf90d63efc" checksum = "a3b095b26f2a2df70be1805d3590eeb9d7a05ecb5be9649b82defc72dc56228c"
dependencies = [ dependencies = [
"cairo-rs", "cairo-rs",
"field-offset", "field-offset",
@ -376,9 +410,9 @@ dependencies = [
[[package]] [[package]]
name = "gtk4-macros" name = "gtk4-macros"
version = "0.7.1" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae9f2c4530f3168fe506b0be7bc15f7a93ef38d020edb27d81a921a26cbca851" checksum = "d57ec49cf9b657f69a05bca8027cff0a8dfd0c49e812be026fc7311f2163832f"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"proc-macro-crate", "proc-macro-crate",
@ -390,9 +424,9 @@ dependencies = [
[[package]] [[package]]
name = "gtk4-sys" name = "gtk4-sys"
version = "0.7.0" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19fde71ef2e78ac8fb18073c345b5f29609048d4045a345613645aa1163243c1" checksum = "7b0bdde87c50317b4f355bcbb4a9c2c414ece1b7c824fb4ad4ba8f3bdb2c6603"
dependencies = [ dependencies = [
"cairo-sys-rs", "cairo-sys-rs",
"gdk-pixbuf-sys", "gdk-pixbuf-sys",
@ -431,9 +465,9 @@ dependencies = [
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.6" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]] [[package]]
name = "libadwaita" name = "libadwaita"
@ -475,15 +509,15 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.19" version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]] [[package]]
name = "memoffset" name = "memoffset"
@ -536,9 +570,9 @@ dependencies = [
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.10" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -588,18 +622,18 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.63" version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.29" version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -615,15 +649,29 @@ dependencies = [
[[package]] [[package]]
name = "semver" name = "semver"
version = "1.0.17" version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.164" version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.31",
]
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
@ -647,18 +695,18 @@ dependencies = [
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.8" version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.10.0" version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
[[package]] [[package]]
name = "syn" name = "syn"
@ -673,9 +721,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.22" version = "2.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -697,9 +745,9 @@ dependencies = [
[[package]] [[package]]
name = "target-lexicon" name = "target-lexicon"
version = "0.12.8" version = "0.12.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
[[package]] [[package]]
name = "termcolor" name = "termcolor"
@ -712,30 +760,31 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.40" version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.40" version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.22", "syn 2.0.31",
] ]
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.22" version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48"
dependencies = [ dependencies = [
"deranged",
"itoa", "itoa",
"libc", "libc",
"num_threads", "num_threads",
@ -752,18 +801,18 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
[[package]] [[package]]
name = "time-macros" name = "time-macros"
version = "0.2.9" version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572"
dependencies = [ dependencies = [
"time-core", "time-core",
] ]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.7.5" version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebafdf5ad1220cb59e7d17cf4d2c72015297b75b19a10472f99b89225089240" checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
dependencies = [ dependencies = [
"serde", "serde",
"serde_spanned", "serde_spanned",
@ -782,9 +831,9 @@ dependencies = [
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.19.11" version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde", "serde",
@ -795,9 +844,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.9" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]] [[package]]
name = "version-compare" name = "version-compare"
@ -811,6 +860,12 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -844,9 +899,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.4.7" version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
adw = { version = "0.5.2", package = "libadwaita", features = ["v1_3"] } adw = { version = "0.5.2", package = "libadwaita", features = ["v1_3"] }
f-uuid = { version = "1.0.0", registry = "gitea" }
gtk = { version = "0.7.1", package = "gtk4", features = ["v4_10"] } gtk = { version = "0.7.1", package = "gtk4", features = ["v4_10"] }
log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] } log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] }
simplelog = "^0.12.0" simplelog = "^0.12.0"

View File

@ -1,12 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<interface> <interface>
<template class="ConfigManagerAppView" parent="GtkBox"> <template class="CmAppView" parent="GtkBox">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<child> <child>
<object class="GtkButton"> <object class="GtkButton" id="button">
<property name="label" translatable="yes">_Test</property>
<property name="halign">center</property> <property name="halign">center</property>
<property name="child">
<object class="AdwButtonContent">
<property name="icon-name">user-trash-symbolic</property>
<property name="label" translatable="yes">Remove</property>
</object>
</property>
<style>
<class name="destructive-action" />
</style>
</object> </object>
</child> </child>
</template> </template>

View File

@ -129,7 +129,7 @@
</child> </child>
<!-- Content --> <!-- Content -->
<child> <child>
<object class="CmAppView" /> <object class="CmAppView" id="app_view" />
</child> </child>
</object> </object>
</child> </child>

View File

@ -1,12 +1,19 @@
use std::cell::RefCell;
use adw::glib; use adw::glib;
use glib::subclass::InitializingObject; use glib::subclass::InitializingObject;
use gtk::CompositeTemplate; use gtk::{Button, CompositeTemplate};
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use crate::ui::objects::app::AppObject;
#[derive(Default, CompositeTemplate)] #[derive(Default, CompositeTemplate)]
#[template(resource = "dev/fyloz/example/app_view.ui")] #[template(resource = "/dev/fyloz/example/app_view.ui")]
pub struct AppView {} pub struct AppView {
#[template_child]
pub button: TemplateChild<Button>,
pub application: RefCell<Option<AppObject>>
}
#[glib::object_subclass] #[glib::object_subclass]
impl ObjectSubclass for AppView { impl ObjectSubclass for AppView {
@ -23,9 +30,7 @@ impl ObjectSubclass for AppView {
} }
} }
impl ObjectImpl for AppView { impl ObjectImpl for AppView {}
}
impl WidgetImpl for AppView {} impl WidgetImpl for AppView {}

View File

@ -1,4 +1,7 @@
use adw::glib; use adw::glib;
use adw::subclass::prelude::*;
use crate::ui::objects::app::AppObject;
mod imp; mod imp;
@ -7,3 +10,9 @@ glib::wrapper! {
@extends gtk::Box, gtk::Widget, @extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable; @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
} }
impl AppView {
pub fn set_application(&self, app: AppObject) {
self.imp().application.replace(Some(app));
}
}

View File

@ -8,6 +8,8 @@ use gtk::glib;
#[derive(Properties, Default)] #[derive(Properties, Default)]
#[properties(wrapper_type = super::AppObject)] #[properties(wrapper_type = super::AppObject)]
pub struct AppObject { pub struct AppObject {
#[property(get, set)]
pub id: RefCell<String>,
#[property(get, set)] #[property(get, set)]
pub name: RefCell<String>, pub name: RefCell<String>,
#[property(get, set)] #[property(get, set)]

View File

@ -1,7 +1,8 @@
mod imp; mod imp;
use adw::prelude::*; use std::str::FromStr;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use f_uuid::Uuid;
use glib::Object; use glib::Object;
use gtk::glib; use gtk::glib;
@ -11,26 +12,37 @@ glib::wrapper! {
impl AppObject { impl AppObject {
pub fn new(name: &str, path: &str) -> Self { pub fn new(name: &str, path: &str) -> Self {
let id = Uuid::new_random();
AppObject::from_fields(id, name, path)
}
pub fn from_fields(id: Uuid, name: &str, path: &str) -> Self {
Object::builder() Object::builder()
.property("id", id.to_string())
.property("name", name) .property("name", name)
.property("path", path) .property("path", path)
.build() .build()
} }
pub fn to_app_data(&self) -> AppData { pub fn to_app_data(&self) -> AppData {
let id_str = &self.imp().id.borrow();
let id = Uuid::from_str(id_str).unwrap();
let name = self.imp().name.borrow().clone(); let name = self.imp().name.borrow().clone();
let path = self.imp().path.borrow().clone(); let path = self.imp().path.borrow().clone();
AppData { name, path } AppData { id, name, path }
} }
pub fn from_app_data(app_data: &AppData) -> Self { pub fn from_app_data(app_data: &AppData) -> Self {
Self::new(&app_data.name, &app_data.path) Self::from_fields(app_data.id, &app_data.name, &app_data.path)
} }
} }
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct AppData { pub struct AppData {
pub id: Uuid,
pub name: String, pub name: String,
pub path: String pub path: String
} }

View File

@ -5,6 +5,7 @@ use crate::ui::objects::app::{AppData, AppObject};
use adw::prelude::*; use adw::prelude::*;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use f_uuid::Uuid;
use gtk::{gio, glib, Entry, ListBoxRow, Label, pango, SelectionMode, Button, Orientation, CenterBox}; use gtk::{gio, glib, Entry, ListBoxRow, Label, pango, SelectionMode, Button, Orientation, CenterBox};
use glib::{clone, Object}; use glib::{clone, Object};
@ -126,10 +127,12 @@ impl Window {
fn restore_data(&self) { fn restore_data(&self) {
let data = vec!( let data = vec!(
AppData { AppData {
id: Uuid::new_random(),
name: "IntelliJ".to_string(), name: "IntelliJ".to_string(),
path: "/home/william/.config/jetbrains/intellij".to_string(), path: "/home/william/.config/jetbrains/intellij".to_string(),
}, },
AppData { AppData {
id: Uuid::new_random(),
name: "Spotify".to_string(), name: "Spotify".to_string(),
path: "/home/william/.config/spotify".to_string(), path: "/home/william/.config/spotify".to_string(),
}); });
@ -153,6 +156,7 @@ impl Window {
} }
fn set_current_app(&self, app: AppObject) { fn set_current_app(&self, app: AppObject) {
self.imp().app_view.set_application(app.clone());
self.imp().current_app.replace(Some(app)); self.imp().current_app.replace(Some(app));
self.select_app_row(); self.select_app_row();
} }