introduce sqlite backend
This commit is contained in:
parent
dbcecd9352
commit
19c7824a0e
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
/target/
|
||||
/src/data/target/
|
||||
/src/gui/target/
|
||||
|
||||
361
Cargo.lock
generated
361
Cargo.lock
generated
@ -22,9 +22,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.65"
|
||||
version = "1.0.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602"
|
||||
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
@ -46,28 +46,29 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.11.0"
|
||||
version = "3.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
|
||||
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
||||
|
||||
[[package]]
|
||||
name = "cairo-rs"
|
||||
version = "0.15.12"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc"
|
||||
checksum = "08f9ee4a4ca9239c9a839453dce04b7ddee2f859ec4cd7acd1f5703b68db549c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-sys-rs",
|
||||
"glib",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cairo-sys-rs"
|
||||
version = "0.15.1"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
|
||||
checksum = "5119ea655ec777b523f0b57279e70f8a4542f61b0e98a48f892b4ef043fd4c5d"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
@ -82,9 +83,9 @@ checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.10.3"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db"
|
||||
checksum = "b0357a6402b295ca3a86bc148e84df46c02e41f41fef186bda662557ef6328aa"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
@ -121,12 +122,97 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codespan-reporting"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
|
||||
dependencies = [
|
||||
"termcolor",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
|
||||
[[package]]
|
||||
name = "cxx"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxxbridge-flags",
|
||||
"cxxbridge-macro",
|
||||
"link-cplusplus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxx-build"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"codespan-reporting",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"scratch",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-flags"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a"
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-macro"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "data"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"diesel",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "diesel"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68c186a7418a2aac330bb76cde82f16c36b03a66fb91db32d20214311f9f6545"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"diesel_derives",
|
||||
"libsqlite3-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "diesel_derives"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "143b758c91dbc3fe1fdcb0dba5bd13276c6a66422f2ef5795b58488248a310aa"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
@ -228,24 +314,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050"
|
||||
checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf"
|
||||
checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab"
|
||||
checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
@ -254,23 +340,35 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68"
|
||||
checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1"
|
||||
checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.24"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90"
|
||||
checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-macro",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
@ -279,9 +377,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gdk-pixbuf"
|
||||
version = "0.15.11"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a"
|
||||
checksum = "c0fb526c8c3a075eda15f961820edf3e15fe18576ac4fbabbb324e4cc6c421e6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"gdk-pixbuf-sys",
|
||||
@ -292,9 +390,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gdk-pixbuf-sys"
|
||||
version = "0.15.10"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7"
|
||||
checksum = "7df12d15c10c3c5a84d9fb4ba0e27659f6a2bdee4f27f8b17126da15d5ddd3f2"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
@ -305,9 +403,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gdk4"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fabb7cf843c26b085a5d68abb95d0c0bf27a9ae2eeff9c4adb503a1eb580876"
|
||||
checksum = "66fe07f362c977c4684d1136a29f097208b3ccb2013ab6f441a3c60a046fd358"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-rs",
|
||||
@ -321,9 +419,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gdk4-sys"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "efe7dcb44f5c00aeabff3f69abfc5673de46559070f89bd3fbb7b66485d9cef2"
|
||||
checksum = "ddcf9e3ab5f237bb641e7f2fccc4b26d5b86f111f0d62e27d452dc24964541c2"
|
||||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
@ -338,9 +436,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.7"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
|
||||
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@ -369,26 +467,29 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.15.12"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b"
|
||||
checksum = "3025f17aab38ebbb40d785806cf36c292c4dd6755b05584fc52d34fb87533263"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.15.10"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d"
|
||||
checksum = "6da1bba9d3f2ab13a6e9932c40f240dc99ebc9f0bdc35cfb130d1a3df36f374c"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
@ -399,15 +500,17 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.15.12"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d"
|
||||
checksum = "079d580b26ee5eb504942bd4340a1218323a4cf19a31d776d62cd3a2a8416622"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib-macros",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
@ -418,10 +521,16 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.15.11"
|
||||
name = "glib-build-tools"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25a68131a662b04931e71891fb14aaf65ee4b44d08e8abc10f49e77418c86c64"
|
||||
checksum = "b70aae3c71f39e3d902e2e842b316e5271f504c3495ad4991aa6e7b7b11dad55"
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e195c1311fa6b04d7b896ea39385f6bd60ef5d25bf74a7c11c8c3f94f6c1a572"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
@ -434,9 +543,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.15.10"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4"
|
||||
checksum = "b33357bb421a77bd849f6a0bfcaf3b4b256a2577802971bb5dd522d530f27021"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps",
|
||||
@ -444,9 +553,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.15.10"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a"
|
||||
checksum = "63ca11a57400f3d4fda594e002844be47900c9fb8b29e2155c6e37a1f24e51b3"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
@ -455,9 +564,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "graphene-rs"
|
||||
version = "0.15.1"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c54f9fbbeefdb62c99f892dfca35f83991e2cb5b46a8dc2a715e58612f85570"
|
||||
checksum = "95a8de4506a64776d90fedf9c28fdca5a7127f8cc9c78976e8184ac6f42685d8"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"graphene-sys",
|
||||
@ -466,9 +575,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "graphene-sys"
|
||||
version = "0.15.10"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa691fc7337ba1df599afb55c3bcb85c04f1b3f17362570e9bb0ff0d1bc3028a"
|
||||
checksum = "f2c952f764f02f8546fcc5d014bc78aa704c6d453c828c8b429121f704349163"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
@ -478,9 +587,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gsk4"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05e9020d333280b3aa38d496495bfa9b50712eebf1ad63f0ec5bcddb5eb61be4"
|
||||
checksum = "d4fc2b86c751a7fe9aad0fdba85937a6aace3a8453e0e2a08d2a31ce4bb8ae55"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-rs",
|
||||
@ -494,9 +603,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gsk4-sys"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7add39ccf60078508c838643a2dcc91f045c46ed63b5ea6ab701b2e25bda3fea"
|
||||
checksum = "2cb53e25cbbe3fa8e3e9db7c06d65085086fadbec4cd0aa567b2e2a4917db83d"
|
||||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk4-sys",
|
||||
@ -513,6 +622,7 @@ name = "gtimelog4"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gettext-rs",
|
||||
"glib-build-tools",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
"rtimelog",
|
||||
@ -520,9 +630,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gtk4"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c64f0c2a3d80e899dc3febddad5bac193ffcf74a0fd7e31037f30dd34d6f7396"
|
||||
checksum = "954e5a318221d69301c80f71cc2d2c15d0d4e259b1b253cad762e93f251bf6d6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-rs",
|
||||
@ -543,24 +653,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gtk4-macros"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fafbcc920af4eb677d7d164853e7040b9de5a22379c596f570190c675d45f7a7"
|
||||
checksum = "ce5eb86364b216ee8c497b1121831168fb25130d3378495a135f8e5c1972db7b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"proc-macro-crate",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quick-xml",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gtk4-sys"
|
||||
version = "0.4.8"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bc8006eea634b7c72da3ff79e24606e45f21b3b832a3c5a1f543f5f97eb0f63"
|
||||
checksum = "0f04bd0b63d999a36ae53a916ee4b20ea64a3ef4732ca8a98b1fde4a22c1476c"
|
||||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
@ -583,22 +692,33 @@ checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.50"
|
||||
version = "0.1.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0"
|
||||
checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "0.7.3"
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06"
|
||||
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
|
||||
dependencies = [
|
||||
"cxx",
|
||||
"cxx-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e481ccbe3dea62107216d0d1138bb8ad8e5e5c43009a098bd1990272c497b0"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
@ -617,9 +737,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libadwaita"
|
||||
version = "0.2.0-alpha.3"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73815fa30ca62d1db2713fe87cfd1cea41cad076ccdece6bb8328032db152f47"
|
||||
checksum = "ed92f031cf7f3d501b84f41e4d05aed6ebfd8eed59a8fc0cccbf51359e92c8e3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
@ -636,9 +756,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libadwaita-sys"
|
||||
version = "0.2.0-alpha.3"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b91960ec236b6fecdace0491ae1e4aac938d1c6adffd5939f811f3ed6592a59e"
|
||||
checksum = "9ec4243e86fb53d06df2461d543529a640c9a0fba2d4cc850b70e11a85f9d952"
|
||||
dependencies = [
|
||||
"gdk4-sys",
|
||||
"gio-sys",
|
||||
@ -652,9 +772,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.134"
|
||||
version = "0.2.135"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
|
||||
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.25.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f0455f2c1bc9a7caa792907026e469c1d91761fb0ea37cbb16427c77280cf35"
|
||||
dependencies = [
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
@ -719,15 +858,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.23.1"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6"
|
||||
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memoffset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -786,11 +923,12 @@ checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
|
||||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.15.10"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f"
|
||||
checksum = "7208c60f224cf6e44c551df5ee2ef38f9da0fd29d7c5a0402000b8ab0520e798"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"gio",
|
||||
"glib",
|
||||
"libc",
|
||||
"once_cell",
|
||||
@ -799,9 +937,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pango-sys"
|
||||
version = "0.15.10"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa"
|
||||
checksum = "922441c228366ed98d3534b87bc7c987c50564094c3abbc3513717786419252d"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
@ -874,22 +1012,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
|
||||
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.21"
|
||||
@ -949,6 +1078,7 @@ checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||
[[package]]
|
||||
name = "rtimelog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/martinpitt/rtimelog/#a8f74baa66194bff8b5b177d35f0e98b71ce6dfb"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"dirs",
|
||||
@ -980,9 +1110,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustyline"
|
||||
version = "9.1.2"
|
||||
version = "10.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db7826789c0e25614b03e5a54a0717a86f9ff6e6e5247f92b369472869320039"
|
||||
checksum = "1d1cd5ae51d3f7bf65d7969d579d502168ef578f289452bd8ccc91de28fda20e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@ -995,7 +1125,6 @@ dependencies = [
|
||||
"nix",
|
||||
"radix_trie",
|
||||
"scopeguard",
|
||||
"smallvec",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
"utf8parse",
|
||||
@ -1008,6 +1137,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "scratch"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.11.0"
|
||||
@ -1028,9 +1163,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.145"
|
||||
version = "1.0.147"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
|
||||
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
@ -1055,9 +1190,9 @@ checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.102"
|
||||
version = "1.0.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"
|
||||
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1066,9 +1201,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "6.0.2"
|
||||
version = "6.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1a45a1c4c9015217e12347f2a411b57ce2c4fc543913b14b6fe40483328e709"
|
||||
checksum = "2955b1fe31e1fa2fbd1976b71cc69a606d7d4da16f6de3333d0c92d51419aeff"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
@ -1083,6 +1218,15 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af547b166dd1ea4b472165569fc456cfb6818116f854690b0ff205e636523dab"
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.37"
|
||||
@ -1131,9 +1275,9 @@ checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
|
||||
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
@ -1153,6 +1297,12 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372"
|
||||
|
||||
[[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.1.0"
|
||||
@ -1247,6 +1397,15 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
||||
22
Cargo.toml
22
Cargo.toml
@ -1,17 +1,5 @@
|
||||
[package]
|
||||
name = "gtimelog4"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
gettext-rs = { version = "0.7", features = ["gettext-system"] }
|
||||
gtk = { version = "0.4.8", package = "gtk4" }
|
||||
rtimelog = { path = "/home/gunibert/Projekte/rtimelog" }
|
||||
|
||||
[dependencies.adw]
|
||||
package = "libadwaita"
|
||||
version = "0.2.0-alpha.2"
|
||||
# features = ["v1_2"]
|
||||
|
||||
[build-dependencies]
|
||||
gtk = { version = "0.4.8", package = "gtk4" }
|
||||
[workspace]
|
||||
members = [
|
||||
"src/gui",
|
||||
"src/data",
|
||||
]
|
||||
7
src/data/Cargo.lock
generated
Normal file
7
src/data/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "data"
|
||||
version = "0.1.0"
|
||||
10
src/data/Cargo.toml
Normal file
10
src/data/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "data"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
diesel = { version = "2.0.2", features = ["chrono", "sqlite", "returning_clauses_for_sqlite_3_35"] }
|
||||
chrono = "0.4.22"
|
||||
BIN
src/data/data.db
Normal file
BIN
src/data/data.db
Normal file
Binary file not shown.
8
src/data/diesel.toml
Normal file
8
src/data/diesel.toml
Normal file
@ -0,0 +1,8 @@
|
||||
# For documentation on how to configure this file,
|
||||
# see https://diesel.rs/guides/configuring-diesel-cli
|
||||
|
||||
[print_schema]
|
||||
file = "src/schema.rs"
|
||||
|
||||
[migrations_directory]
|
||||
dir = "migrations"
|
||||
0
src/data/migrations/.keep
Normal file
0
src/data/migrations/.keep
Normal file
3
src/data/migrations/2022-10-22-182216_initial/down.sql
Normal file
3
src/data/migrations/2022-10-22-182216_initial/down.sql
Normal file
@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
|
||||
DROP TABLE entries;
|
||||
8
src/data/migrations/2022-10-22-182216_initial/up.sql
Normal file
8
src/data/migrations/2022-10-22-182216_initial/up.sql
Normal file
@ -0,0 +1,8 @@
|
||||
-- Your SQL goes here
|
||||
|
||||
CREATE TABLE IF NOT EXISTS entries (
|
||||
id INTEGER PRIMARY KEY NOT NULL,
|
||||
start TIMESTAMP,
|
||||
stop TIMESTAMP,
|
||||
task TEXT
|
||||
);
|
||||
105
src/data/src/lib.rs
Normal file
105
src/data/src/lib.rs
Normal file
@ -0,0 +1,105 @@
|
||||
use chrono::{Datelike, NaiveDateTime};
|
||||
use diesel::{AsChangeset, Connection, Identifiable, Insertable, Queryable, RunQueryDsl, SqliteConnection};
|
||||
|
||||
use schema::entries;
|
||||
|
||||
mod schema;
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, AsChangeset)]
|
||||
#[diesel(table_name = entries)]
|
||||
pub struct Entry {
|
||||
id: i32,
|
||||
start: Option<NaiveDateTime>,
|
||||
stop: Option<NaiveDateTime>,
|
||||
task: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
#[diesel(table_name = entries)]
|
||||
pub struct NewEntry {
|
||||
start: Option<NaiveDateTime>,
|
||||
stop: Option<NaiveDateTime>,
|
||||
task: Option<String>,
|
||||
}
|
||||
|
||||
pub struct Timelog {
|
||||
entries: Vec<Entry>,
|
||||
}
|
||||
|
||||
impl Timelog {
|
||||
pub fn new() -> Self {
|
||||
use schema::entries::dsl::*;
|
||||
|
||||
let mut conn = get_connection();
|
||||
|
||||
let items: Vec<Entry> = entries.load(&mut conn).expect("Could not load entries");
|
||||
|
||||
|
||||
Self {
|
||||
entries: items
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_entry<P: AsRef<str>>(&mut self, task_name: P) {
|
||||
use schema::entries::dsl::*;
|
||||
|
||||
let mut conn = get_connection();
|
||||
let entry = NewEntry {
|
||||
start: Some(chrono::Local::now().naive_local()),
|
||||
stop: None,
|
||||
task: Some(task_name.as_ref().to_string()),
|
||||
};
|
||||
|
||||
let saved_entry = diesel::insert_into(entries).values(&entry).get_result::<Entry>(&mut conn).expect("Error saving entry");
|
||||
|
||||
self.entries.push(saved_entry);
|
||||
}
|
||||
|
||||
pub fn update_entry(&self, item: &Entry) {
|
||||
let mut conn = get_connection();
|
||||
diesel::update(item).set(item).execute(&mut conn).expect("Could not update Entry");
|
||||
}
|
||||
|
||||
pub fn get_today(&self) -> Vec<&Entry> {
|
||||
let now = chrono::Local::now();
|
||||
let today_entries: Vec<_> = self.entries.iter().filter(|entry| {
|
||||
if let Some(start) = entry.start {
|
||||
if start.day() == now.day() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).collect();
|
||||
|
||||
return today_entries;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_connection() -> SqliteConnection {
|
||||
let database_url = "sqlite://data.db";
|
||||
SqliteConnection::establish(database_url).unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_save_entry() {
|
||||
let mut timelog = Timelog::new();
|
||||
|
||||
timelog.add_entry("MyTask");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_update_entry() {
|
||||
let mut timelog = Timelog::new();
|
||||
|
||||
let e: &Entry = {
|
||||
let e = timelog.entries.first_mut().unwrap();
|
||||
e.task = Some(String::from("Changed taskname"));
|
||||
timelog.entries.first().unwrap()
|
||||
};
|
||||
timelog.update_entry(e);
|
||||
}
|
||||
}
|
||||
10
src/data/src/schema.rs
Normal file
10
src/data/src/schema.rs
Normal file
@ -0,0 +1,10 @@
|
||||
// @generated automatically by Diesel CLI.
|
||||
|
||||
diesel::table! {
|
||||
entries (id) {
|
||||
id -> Integer,
|
||||
start -> Nullable<Timestamp>,
|
||||
stop -> Nullable<Timestamp>,
|
||||
task -> Nullable<Text>,
|
||||
}
|
||||
}
|
||||
1311
src/gui/Cargo.lock
generated
Normal file
1311
src/gui/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
src/gui/Cargo.toml
Normal file
18
src/gui/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "gtimelog4"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
gettext-rs = { version = "0.7", features = ["gettext-system"] }
|
||||
gtk = { version = "0.5.0", package = "gtk4" }
|
||||
#rtimelog = { path = "/home/gunibert/Projekte/rtimelog" }
|
||||
rtimelog = { git = "https://github.com/martinpitt/rtimelog/"}
|
||||
|
||||
[dependencies.adw]
|
||||
package = "libadwaita"
|
||||
version = "0.2.0-alpha.2"
|
||||
# features = ["v1_2"]
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.16.0"
|
||||
@ -1,7 +1,6 @@
|
||||
use gtk::gio;
|
||||
|
||||
fn main() {
|
||||
gio::compile_resources(
|
||||
glib_build_tools::compile_resources(
|
||||
"src",
|
||||
"src/gtimelog4.gresource.xml",
|
||||
"gtimelog4.gresource",
|
||||
@ -27,6 +27,7 @@ use crate::config::VERSION;
|
||||
use crate::Gtimelog4Window;
|
||||
|
||||
mod imp {
|
||||
use std::path::PathBuf;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
@ -40,13 +41,13 @@ mod imp {
|
||||
}
|
||||
|
||||
impl ObjectImpl for Gtimelog4Application {
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.parent_constructed(obj);
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
let obj = self.instance();
|
||||
|
||||
obj.setup_gactions();
|
||||
obj.set_accels_for_action("app.quit", &["<primary>q"]);
|
||||
|
||||
let timelog = rtimelog::store::Timelog::new_from_default_file();
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,12 +56,15 @@ mod imp {
|
||||
// has been launched. Additionally, this callback notifies us when the user
|
||||
// tries to launch a "second instance" of the application. When they try
|
||||
// to do that, we'll just present any existing window.
|
||||
fn activate(&self, application: &Self::Type) {
|
||||
fn activate(&self) {
|
||||
let application = self.instance();
|
||||
// Get the current window or create one if necessary
|
||||
let window = if let Some(window) = application.active_window() {
|
||||
window
|
||||
} else {
|
||||
let window = Gtimelog4Window::new(application);
|
||||
let timelog = rtimelog::store::Timelog::new_from_file(&PathBuf::from("/home/gunibert/.local/share/gtimelog/timelog.txt"));
|
||||
let window = Gtimelog4Window::new(&*application);
|
||||
window.set_timelog(timelog);
|
||||
window.upcast()
|
||||
};
|
||||
|
||||
@ -81,8 +85,7 @@ glib::wrapper! {
|
||||
|
||||
impl Gtimelog4Application {
|
||||
pub fn new(application_id: &str, flags: &gio::ApplicationFlags) -> Self {
|
||||
glib::Object::new(&[("application-id", &application_id), ("flags", flags)])
|
||||
.expect("Failed to create Gtimelog4Application")
|
||||
glib::Object::new::<Gtimelog4Application>(&[("application-id", &application_id), ("flags", flags)])
|
||||
}
|
||||
|
||||
fn setup_gactions(&self) {
|
||||
100
src/gui/src/timeentry.rs
Normal file
100
src/gui/src/timeentry.rs
Normal file
@ -0,0 +1,100 @@
|
||||
use glib::Boxed;
|
||||
use gtk::glib;
|
||||
use gtk::glib::ToValue;
|
||||
use gtk::subclass::prelude::{ObjectSubclassExt, ObjectSubclassIsExt};
|
||||
|
||||
#[derive(glib::Boxed, Clone, Default)]
|
||||
#[boxed_type(name = "Entry")]
|
||||
pub struct Entry(rtimelog::store::Entry);
|
||||
|
||||
impl From<rtimelog::store::Entry> for Entry {
|
||||
fn from(rentry: rtimelog::store::Entry) -> Self {
|
||||
Self(rentry)
|
||||
}
|
||||
}
|
||||
|
||||
mod imp {
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use gtk::glib::once_cell::sync::Lazy;
|
||||
use super::*;
|
||||
use gtk::subclass::prelude::{ObjectImpl, ObjectSubclass};
|
||||
use crate::gio::glib::{ParamSpec, Value};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TimeEntry {
|
||||
pub(crate) entry: RefCell<Entry>,
|
||||
}
|
||||
|
||||
impl TimeEntry {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for TimeEntry {
|
||||
const NAME: &'static str = "TimeEntry";
|
||||
type Type = super::TimeEntry;
|
||||
type ParentType = glib::Object;
|
||||
}
|
||||
|
||||
impl ObjectImpl for TimeEntry {
|
||||
fn properties() -> &'static [ParamSpec] {
|
||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||
vec![
|
||||
glib::ParamSpecBoxed::builder::<Entry>("entry").build(),
|
||||
glib::ParamSpecString::builder("task").build()
|
||||
]
|
||||
});
|
||||
PROPERTIES.as_ref()
|
||||
}
|
||||
|
||||
fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) {
|
||||
match pspec.name() {
|
||||
"entry" => {
|
||||
let e = value.get().expect("Something went wrong");
|
||||
self.entry.replace(e);
|
||||
}
|
||||
"task" => {
|
||||
let e = value.get().expect("Something went wrong");
|
||||
println!("Set Task: {}", e);
|
||||
self.entry.borrow_mut().0.task = e;
|
||||
}
|
||||
_ => unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
fn property(&self, _id: usize, pspec: &ParamSpec) -> Value {
|
||||
match pspec.name() {
|
||||
"entry" => self.entry.borrow().to_value(),
|
||||
"task" => {
|
||||
println!("Task: {}", self.entry.borrow().0.task);
|
||||
self.entry.borrow().0.task.to_value()
|
||||
},
|
||||
_ => unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct TimeEntry(ObjectSubclass<imp::TimeEntry>);
|
||||
}
|
||||
|
||||
impl TimeEntry {
|
||||
pub fn new(entry: rtimelog::store::Entry) -> Self {
|
||||
let e: Entry = entry.into();
|
||||
glib::Object::new(&[("entry", &e.to_value())])
|
||||
}
|
||||
|
||||
pub fn get_task(&self) -> String {
|
||||
self.imp().entry.borrow().0.task.clone()
|
||||
}
|
||||
|
||||
pub fn get_time(&self) -> String {
|
||||
self.imp().entry.borrow().0.stop.format("%T").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<rtimelog::store::Entry> for TimeEntry {
|
||||
fn from(entry: rtimelog::store::Entry) -> Self {
|
||||
TimeEntry::new(entry)
|
||||
}
|
||||
}
|
||||
153
src/gui/src/window.rs
Normal file
153
src/gui/src/window.rs
Normal file
@ -0,0 +1,153 @@
|
||||
/* window.rs
|
||||
*
|
||||
* Copyright 2022 Günther Wagner
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
use gtk::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use gtk::{gio, glib, CompositeTemplate};
|
||||
use crate::timeentry::TimeEntry;
|
||||
|
||||
mod imp {
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use gtk::{ListItem, SignalListItemFactory};
|
||||
use gtk::glib::clone;
|
||||
use crate::gio::glib::signal::Inhibit;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(resource = "/de/gunibert/gtimelog4/window.ui")]
|
||||
pub struct Gtimelog4Window {
|
||||
pub timelog: Rc<RefCell<rtimelog::store::Timelog>>,
|
||||
|
||||
// Template widgets
|
||||
#[template_child]
|
||||
pub header_bar: TemplateChild<gtk::HeaderBar>,
|
||||
#[template_child]
|
||||
pub columnview: TemplateChild<gtk::ColumnView>,
|
||||
#[template_child]
|
||||
pub time_column: TemplateChild<gtk::ColumnViewColumn>,
|
||||
#[template_child]
|
||||
pub task_column: TemplateChild<gtk::ColumnViewColumn>,
|
||||
#[template_child]
|
||||
pub taskentry: TemplateChild<gtk::Entry>,
|
||||
}
|
||||
|
||||
impl Gtimelog4Window {
|
||||
fn setup_lbl(_: &SignalListItemFactory, item: &ListItem) {
|
||||
let lbl = gtk::EditableLabel::new("");
|
||||
lbl.set_xalign(0.0f32);
|
||||
item.set_child(Some(&lbl));
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Gtimelog4Window {
|
||||
const NAME: &'static str = "Gtimelog4Window";
|
||||
type Type = super::Gtimelog4Window;
|
||||
type ParentType = adw::ApplicationWindow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
Self::bind_template(klass);
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for Gtimelog4Window {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
|
||||
let task_factory = SignalListItemFactory::new();
|
||||
task_factory.connect_setup(Gtimelog4Window::setup_lbl);
|
||||
task_factory.connect_bind(|_factory, item| {
|
||||
if let (Some(lbl), Some(entry)) = (item.child(), item.item()) {
|
||||
let mylbl = lbl.downcast::<gtk::EditableLabel>().unwrap();
|
||||
let entry = entry.downcast::<TimeEntry>().unwrap();
|
||||
println!("Initial Task: {}", entry.property::<String>("task"));
|
||||
entry.bind_property("task", &mylbl, "text").sync_create().bidirectional().build();
|
||||
}
|
||||
});
|
||||
|
||||
self.task_column.set_factory(Some(&task_factory));
|
||||
|
||||
let time_factory = SignalListItemFactory::new();
|
||||
time_factory.connect_setup(Gtimelog4Window::setup_lbl);
|
||||
time_factory.connect_bind(|_factory, item| {
|
||||
if let (Some(lbl), Some(entry)) = (item.child(), item.item()) {
|
||||
let mylbl = lbl.downcast::<gtk::EditableLabel>().unwrap();
|
||||
let entry = entry.downcast::<TimeEntry>().unwrap();
|
||||
mylbl.set_text(&entry.get_time());
|
||||
}
|
||||
});
|
||||
|
||||
self.time_column.set_factory(Some(&time_factory));
|
||||
|
||||
self.taskentry.connect_activate(clone!(@strong self.timelog as timelog, @strong self.columnview as columnview => move |entry| {
|
||||
timelog.borrow_mut().add(entry.text().to_string());
|
||||
timelog.borrow_mut().save();
|
||||
|
||||
let entries: Vec<TimeEntry> = timelog.borrow().get_today().to_vec().into_iter().map(|entry| entry.into()).collect();
|
||||
let model = gio::ListStore::new(TimeEntry::static_type());
|
||||
for entry in entries {
|
||||
model.append(&entry);
|
||||
}
|
||||
columnview.set_model(Some(>k::NoSelection::new(Some(&model))));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for Gtimelog4Window {}
|
||||
|
||||
impl WindowImpl for Gtimelog4Window {
|
||||
fn close_request(&self) -> Inhibit {
|
||||
println!("Close request");
|
||||
self.timelog.borrow_mut().save().expect("TODO: panic message");
|
||||
Inhibit(false)
|
||||
}
|
||||
}
|
||||
|
||||
impl ApplicationWindowImpl for Gtimelog4Window {}
|
||||
|
||||
impl AdwApplicationWindowImpl for Gtimelog4Window {}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Gtimelog4Window(ObjectSubclass<imp::Gtimelog4Window>)
|
||||
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, @implements gio::ActionGroup, gio::ActionMap;
|
||||
}
|
||||
|
||||
impl Gtimelog4Window {
|
||||
pub fn new<P: glib::IsA<gtk::Application>>(application: &P) -> Self {
|
||||
glib::Object::new(&[("application", application)])
|
||||
}
|
||||
|
||||
pub fn set_timelog(&self, timelog: rtimelog::store::Timelog) {
|
||||
self.imp().timelog.replace(timelog);
|
||||
|
||||
let entries: Vec<TimeEntry> = self.imp().timelog.borrow().get_this_week().to_vec().into_iter().map(|entry| entry.into()).collect();
|
||||
let model = gio::ListStore::new(TimeEntry::static_type());
|
||||
for entry in entries {
|
||||
model.append(&entry);
|
||||
}
|
||||
self.imp().columnview.set_model(Some(>k::NoSelection::new(Some(&model))));
|
||||
}
|
||||
}
|
||||
@ -20,11 +20,29 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnView" id="columnview">
|
||||
<property name="vexpand">True</property>
|
||||
<style>
|
||||
<class name="data-table"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="task_column">
|
||||
|
||||
<object class="GtkColumnViewColumn" id="time_column">
|
||||
<property name="title">Time</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="task_column">
|
||||
<property name="title">Task</property>
|
||||
<property name="expand">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="taskentry">
|
||||
<property name="margin-bottom">6</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@ -1,47 +0,0 @@
|
||||
use gtk::glib;
|
||||
use gtk::subclass::prelude::ObjectSubclassExt;
|
||||
use rtimelog::store::Entry;
|
||||
|
||||
mod imp {
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use super::*;
|
||||
use gtk::subclass::prelude::{ObjectImpl, ObjectSubclass};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TimeEntry {
|
||||
pub(crate) entry: Rc<RefCell<rtimelog::store::Entry>>,
|
||||
}
|
||||
|
||||
impl TimeEntry {
|
||||
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for TimeEntry {
|
||||
const NAME: &'static str = "TimeEntry";
|
||||
type Type = super::TimeEntry;
|
||||
type ParentType = glib::Object;
|
||||
}
|
||||
|
||||
impl ObjectImpl for TimeEntry {}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct TimeEntry(ObjectSubclass<imp::TimeEntry>);
|
||||
}
|
||||
|
||||
impl TimeEntry {
|
||||
pub fn new(entry: rtimelog::store::Entry) -> Self {
|
||||
let obj = glib::Object::new(&[]).expect("Could not create TimeEntry");
|
||||
let imp = imp::TimeEntry::from_instance(&obj);
|
||||
imp.entry.replace(entry);
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
||||
impl From<rtimelog::store::Entry> for TimeEntry {
|
||||
fn from(entry: Entry) -> Self {
|
||||
TimeEntry::new(entry)
|
||||
}
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
/* window.rs
|
||||
*
|
||||
* Copyright 2022 Günther Wagner
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
use gtk::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use gtk::{gio, glib, CompositeTemplate};
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(resource = "/de/gunibert/gtimelog4/window.ui")]
|
||||
pub struct Gtimelog4Window {
|
||||
// Template widgets
|
||||
#[template_child]
|
||||
pub header_bar: TemplateChild<gtk::HeaderBar>,
|
||||
#[template_child]
|
||||
pub columnview: TemplateChild<gtk::ColumnView>,
|
||||
#[template_child]
|
||||
pub task_column: TemplateChild<gtk::ColumnViewColumn>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Gtimelog4Window {
|
||||
const NAME: &'static str = "Gtimelog4Window";
|
||||
type Type = super::Gtimelog4Window;
|
||||
type ParentType = adw::ApplicationWindow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
Self::bind_template(klass);
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for Gtimelog4Window {}
|
||||
impl WidgetImpl for Gtimelog4Window {}
|
||||
impl WindowImpl for Gtimelog4Window {}
|
||||
impl ApplicationWindowImpl for Gtimelog4Window {}
|
||||
impl AdwApplicationWindowImpl for Gtimelog4Window {}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Gtimelog4Window(ObjectSubclass<imp::Gtimelog4Window>)
|
||||
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, @implements gio::ActionGroup, gio::ActionMap;
|
||||
}
|
||||
|
||||
impl Gtimelog4Window {
|
||||
pub fn new<P: glib::IsA<gtk::Application>>(application: &P) -> Self {
|
||||
glib::Object::new(&[("application", application)])
|
||||
.expect("Failed to create Gtimelog4Window")
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user