Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-welcome
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-welcome
Commits
181247c0
Commit
181247c0
authored
Oct 19, 2022
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port to latest gtk-rs crates
parent
95892ed1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
152 additions
and
180 deletions
+152
-180
Cargo.lock
Cargo.lock
+92
-80
Cargo.toml
Cargo.toml
+2
-2
application.rs
src/application.rs
+37
-55
utils.rs
src/utils.rs
+0
-14
image_page.rs
src/widgets/image_page.rs
+9
-13
paginator.rs
src/widgets/paginator.rs
+8
-13
window.rs
src/widgets/window.rs
+4
-3
No files found.
Cargo.lock
View file @
181247c0
...
...
@@ -48,22 +48,23 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "cairo-rs"
version = "0.1
5.12
"
version = "0.1
6.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc
"
checksum = "
bd6d010ad1f8103b579afac7713f061e3fc99d101f23928a432e2d42e9bdf249
"
dependencies = [
"bitflags",
"cairo-sys-rs",
"glib",
"libc",
"once_cell",
"thiserror",
]
[[package]]
name = "cairo-sys-rs"
version = "0.1
5.1
"
version = "0.1
6.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8
"
checksum = "
5119ea655ec777b523f0b57279e70f8a4542f61b0e98a48f892b4ef043fd4c5d
"
dependencies = [
"glib-sys",
"libc",
...
...
@@ -78,9 +79,9 @@ checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-expr"
version = "0.1
0.3
"
version = "0.1
1.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db
"
checksum = "
b0357a6402b295ca3a86bc148e84df46c02e41f41fef186bda662557ef6328aa
"
dependencies = [
"smallvec",
]
...
...
@@ -147,6 +148,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68"
[[package]]
name = "futures-macro"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "futures-task"
version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
...
...
@@ -159,6 +171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90"
dependencies = [
"futures-core",
"futures-macro",
"futures-task",
"pin-project-lite",
"pin-utils",
...
...
@@ -167,9 +180,9 @@ dependencies = [
[[package]]
name = "gdk-pixbuf"
version = "0.1
5.11
"
version = "0.1
6.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a
"
checksum = "
c0fb526c8c3a075eda15f961820edf3e15fe18576ac4fbabbb324e4cc6c421e6
"
dependencies = [
"bitflags",
"gdk-pixbuf-sys",
...
...
@@ -180,9 +193,9 @@ dependencies = [
[[package]]
name = "gdk-pixbuf-sys"
version = "0.1
5.1
0"
version = "0.1
6.
0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7
"
checksum = "
7df12d15c10c3c5a84d9fb4ba0e27659f6a2bdee4f27f8b17126da15d5ddd3f2
"
dependencies = [
"gio-sys",
"glib-sys",
...
...
@@ -193,9 +206,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",
...
...
@@ -209,9 +222,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 = "
efe7dcb44f5c00aeabff3f69abfc5673de46559070f89bd3fbb7b66485d9cef
2"
checksum = "
ddcf9e3ab5f237bb641e7f2fccc4b26d5b86f111f0d62e27d452dc24964541c
2"
dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
...
...
@@ -246,26 +259,29 @@ dependencies = [
[[package]]
name = "gio"
version = "0.1
5.12
"
version = "0.1
6.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.1
5.1
0"
version = "0.1
6.
0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d
"
checksum = "
6da1bba9d3f2ab13a6e9932c40f240dc99ebc9f0bdc35cfb130d1a3df36f374c
"
dependencies = [
"glib-sys",
"gobject-sys",
...
...
@@ -276,15 +292,17 @@ dependencies = [
[[package]]
name = "glib"
version = "0.1
5.12
"
version = "0.1
6.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d
"
checksum = "
9d9d01334b55e33e9189fa956dde9885e5439dfa6c448f4d724e222addbf06f2
"
dependencies = [
"bitflags",
"futures-channel",
"futures-core",
"futures-executor",
"futures-task",
"futures-util",
"gio-sys",
"glib-macros",
"glib-sys",
"gobject-sys",
...
...
@@ -296,9 +314,9 @@ dependencies = [
[[package]]
name = "glib-macros"
version = "0.1
5.11
"
version = "0.1
6.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
25a68131a662b04931e71891fb14aaf65ee4b44d08e8abc10f49e77418c86c64
"
checksum = "
e195c1311fa6b04d7b896ea39385f6bd60ef5d25bf74a7c11c8c3f94f6c1a572
"
dependencies = [
"anyhow",
"heck",
...
...
@@ -311,9 +329,9 @@ dependencies = [
[[package]]
name = "glib-sys"
version = "0.1
5.1
0"
version = "0.1
6.
0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4
"
checksum = "
b33357bb421a77bd849f6a0bfcaf3b4b256a2577802971bb5dd522d530f27021
"
dependencies = [
"libc",
"system-deps",
...
...
@@ -333,9 +351,9 @@ dependencies = [
[[package]]
name = "gobject-sys"
version = "0.1
5.1
0"
version = "0.1
6.
0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a
"
checksum = "
63ca11a57400f3d4fda594e002844be47900c9fb8b29e2155c6e37a1f24e51b3
"
dependencies = [
"glib-sys",
"libc",
...
...
@@ -344,9 +362,9 @@ dependencies = [
[[package]]
name = "graphene-rs"
version = "0.1
5.1
"
version = "0.1
6.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
7c54f9fbbeefdb62c99f892dfca35f83991e2cb5b46a8dc2a715e58612f85570
"
checksum = "
95a8de4506a64776d90fedf9c28fdca5a7127f8cc9c78976e8184ac6f42685d8
"
dependencies = [
"glib",
"graphene-sys",
...
...
@@ -355,9 +373,9 @@ dependencies = [
[[package]]
name = "graphene-sys"
version = "0.1
5.1
0"
version = "0.1
6.
0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f
a691fc7337ba1df599afb55c3bcb85c04f1b3f17362570e9bb0ff0d1bc3028a
"
checksum = "f
2c952f764f02f8546fcc5d014bc78aa704c6d453c828c8b429121f704349163
"
dependencies = [
"glib-sys",
"libc",
...
...
@@ -367,9 +385,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",
...
...
@@ -383,9 +401,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",
...
...
@@ -399,9 +417,9 @@ dependencies = [
[[package]]
name = "gtk4"
version = "0.
4.8
"
version = "0.
5.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
c64f0c2a3d80e899dc3febddad5bac193ffcf74a0fd7e31037f30dd34d6f739
6"
checksum = "
954e5a318221d69301c80f71cc2d2c15d0d4e259b1b253cad762e93f251bf6d
6"
dependencies = [
"bitflags",
"cairo-rs",
...
...
@@ -422,24 +440,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",
...
...
@@ -486,10 +503,12 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libadwaita"
version = "0.
1.1
"
version = "0.
2.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
f2ae453d28e3b91f03749f02b1531e8cfe315a1d0762b77a61797d2ab80bb87d
"
checksum = "
ed92f031cf7f3d501b84f41e4d05aed6ebfd8eed59a8fc0cccbf51359e92c8e3
"
dependencies = [
"bitflags",
"futures-channel",
"gdk-pixbuf",
"gdk4",
"gio",
...
...
@@ -503,9 +522,9 @@ dependencies = [
[[package]]
name = "libadwaita-sys"
version = "0.
1
.0"
version = "0.
2
.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
f18b6ac4cadd252a89f5cba0a5a4e99836131795d6fad37b859ac79e8cb7d2c8
"
checksum = "
9ec4243e86fb53d06df2461d543529a640c9a0fba2d4cc850b70e11a85f9d952
"
dependencies = [
"gdk4-sys",
"gio-sys",
...
...
@@ -513,14 +532,15 @@ dependencies = [
"gobject-sys",
"gtk4-sys",
"libc",
"pango-sys",
"system-deps",
]
[[package]]
name = "libc"
version = "0.2.13
3
"
version = "0.2.13
5
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966
"
checksum = "
68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c
"
[[package]]
name = "locale_config"
...
...
@@ -599,17 +619,18 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.1
4
.0"
version = "1.1
5
.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0
"
checksum = "
e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1
"
[[package]]
name = "pango"
version = "0.1
5.1
0"
version = "0.1
6.
0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f
"
checksum = "
7208c60f224cf6e44c551df5ee2ef38f9da0fd29d7c5a0402000b8ab0520e798
"
dependencies = [
"bitflags",
"gio",
"glib",
"libc",
"once_cell",
...
...
@@ -618,9 +639,9 @@ dependencies = [
[[package]]
name = "pango-sys"
version = "0.1
5.1
0"
version = "0.1
6.
0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa
"
checksum = "
922441c228366ed98d3534b87bc7c987c50564094c3abbc3513717786419252d
"
dependencies = [
"glib-sys",
"gobject-sys",
...
...
@@ -630,9 +651,9 @@ dependencies = [
[[package]]
name = "pest"
version = "2.
3.1
"
version = "2.
4.0
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
cb779fcf4bb850fbbb0edc96ff6cf34fd90c4b1a112ce042653280d9a7364048
"
checksum = "
dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a
"
dependencies = [
"thiserror",
"ucd-trie",
...
...
@@ -703,9 +724,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.4
3
"
version = "1.0.4
7
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab
"
checksum = "
5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725
"
dependencies = [
"unicode-ident",
]
...
...
@@ -717,15 +738,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
...
...
@@ -780,9 +792,9 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.14
4
"
version = "1.0.14
5
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860
"
checksum = "
728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b
"
[[package]]
name = "slab"
...
...
@@ -795,15 +807,15 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.
9
.0"
version = "1.
10
.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1
"
checksum = "
a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0
"
[[package]]
name = "syn"
version = "1.0.10
0
"
version = "1.0.10
2
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e
"
checksum = "
3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1
"
dependencies = [
"proc-macro2",
"quote",
...
...
@@ -812,9 +824,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",
...
...
@@ -840,18 +852,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.3
5
"
version = "1.0.3
7
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85
"
checksum = "
10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e
"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.3
5
"
version = "1.0.3
7
"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783
"
checksum = "
982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb
"
dependencies = [
"proc-macro2",
"quote",
...
...
@@ -875,9 +887,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 = "version-compare"
...
...
Cargo.toml
View file @
181247c0
...
...
@@ -6,9 +6,9 @@ edition = "2021"
[dependencies]
gtk
=
{
package
=
"gtk4"
,
version
=
"0.
4
"
,
features=
["v4_2"]
}
gtk
=
{
package
=
"gtk4"
,
version
=
"0.
5
"
,
features=
["v4_2"]
}
log
=
"0.4"
gettext-rs
=
{
version
=
"0.7"
,
features
=
["gettext-system"]
}
adw
=
{package
=
"libadwaita"
,
version
=
"0.
1
"
}
adw
=
{package
=
"libadwaita"
,
version
=
"0.
2
"
}
pretty_env_logger
=
"0.4"
regex
=
"1.5"
src/application.rs
View file @
181247c0
use
crate
::
config
;
use
crate
::
utils
;
use
crate
::
widgets
::
Window
;
use
adw
::
prelude
::
*
;
use
gtk
::{
gio
,
glib
::{
self
,
clone
},
subclass
::
prelude
::
*
,
};
use
log
::
info
;
use
gtk
::{
gio
,
glib
,
subclass
::
prelude
::
*
};
mod
imp
{
use
super
::
*
;
...
...
@@ -28,66 +22,55 @@ mod imp {
impl
ObjectImpl
for
Application
{}
impl
ApplicationImpl
for
Application
{
fn
activate
(
&
self
,
application
:
&
Self
::
Type
)
{
let
window
=
Window
::
new
(
application
);
fn
activate
(
&
self
)
{
self
.parent_activate
();
let
application
=
self
.instance
();
let
window
=
Window
::
new
(
&
application
);
application
.add_window
(
&
window
);
window
.present
();
self
.window
.set
(
window
.downgrade
())
.unwrap
();
self
.parent_activate
(
application
);
}
fn
startup
(
&
self
,
application
:
&
Self
::
Type
)
{
fn
startup
(
&
self
)
{
self
.parent_startup
();
let
application
=
self
.instance
();
// Quit
utils
::
action
(
application
,
"quit"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
application
.quit
();
}),
);
let
quit
=
gio
::
ActionEntry
::
builder
(
"quit"
)
.activate
(
move
|
app
:
&
Self
::
Type
,
_
,
_
|
app
.quit
())
.build
();
// Start Tour
utils
::
action
(
application
,
"start-tour"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
application
.window
()
.start_tour
();
}),
);
let
start_tour
=
gio
::
ActionEntry
::
builder
(
"start-tour"
)
.activate
(
move
|
app
:
&
Self
::
Type
,
_
,
_
|
app
.window
()
.start_tour
())
.build
();
// Skip Tour
utils
::
action
(
application
,
"skip-tour"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
application
.quit
();
}),
);
utils
::
action
(
application
,
"next-page"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
let
window
=
application
.window
();
let
skip_tour
=
gio
::
ActionEntry
::
builder
(
"skip-tour"
)
.activate
(
move
|
app
:
&
Self
::
Type
,
_
,
_
|
app
.quit
())
.build
();
// Next page
let
next_page
=
gio
::
ActionEntry
::
builder
(
"next-page"
)
.activate
(
move
|
app
:
&
Self
::
Type
,
_
,
_
|
{
let
window
=
app
.window
();
if
window
.paginator
()
.try_next
()
.is_none
()
{
window
.close
();
}
}),
);
utils
::
action
(
application
,
"previous-page"
,
clone!
(
@
weak
application
=>
move
|
_
,
_
|
{
let
window
=
application
.window
();
})
.build
();
// Previous page
let
previous_page
=
gio
::
ActionEntry
::
builder
(
"previous-page"
)
.activate
(
move
|
app
:
&
Self
::
Type
,
_
,
_
|
{
let
window
=
app
.window
();
if
window
.paginator
()
.try_previous
()
.is_none
()
{
window
.reset_tour
();
}
}),
);
})
.build
();
application
.add_action_entries
([
quit
,
start_tour
,
skip_tour
,
next_page
,
previous_page
])
.unwrap
();
application
.set_accels_for_action
(
"app.quit"
,
&
[
"<Control>q"
]);
application
.set_accels_for_action
(
"app.skip-tour"
,
&
[
"Escape"
]);
self
.parent_startup
(
application
);
}
}
impl
GtkApplicationImpl
for
Application
{}
...
...
@@ -107,7 +90,6 @@ impl Application {
(
"application-id"
,
&
config
::
APP_ID
),
(
"resource-base-path"
,
&
Some
(
"/org/gnome/Tour"
)),
])
.unwrap
()
}
fn
window
(
&
self
)
->
Window
{
...
...
@@ -115,9 +97,9 @@ impl Application {
}
pub
fn
run
()
{
info!
(
"GNOME Tour ({})"
,
config
::
APP_ID
);
info!
(
"Version: {} ({})"
,
config
::
VERSION
,
config
::
PROFILE
);
info!
(
"Datadir: {}"
,
config
::
PKGDATADIR
);
log
::
info!
(
"GNOME Tour ({})"
,
config
::
APP_ID
);
log
::
info!
(
"Version: {} ({})"
,
config
::
VERSION
,
config
::
PROFILE
);
log
::
info!
(
"Datadir: {}"
,
config
::
PKGDATADIR
);
let
app
=
Self
::
new
();
gtk
::
prelude
::
ApplicationExtManual
::
run
(
&
app
);
}
...
...
src/utils.rs
View file @
181247c0
// based on https://gitlab.gnome.org/World/podcasts/-/blob/master/podcasts-gtk/src/i18n|utils.rs
use
gettextrs
::
gettext
;
use
gtk
::{
gio
,
glib
};
use
regex
::{
Captures
,
Regex
};
pub
fn
action
<
T
,
F
>
(
thing
:
&
T
,
name
:
&
str
,
action
:
F
)
where
T
:
gio
::
traits
::
ActionMapExt
,
for
<
'r
,
's
>
F
:
Fn
(
&
'r
gio
::
SimpleAction
,
Option
<&
glib
::
Variant
>
)
+
'static
,
{
// Create a stateless, parameterless action
let
act
=
gio
::
SimpleAction
::
new
(
name
,
None
);
// Connect the handler
act
.connect_activate
(
action
);
// Add it to the map
thing
.add_action
(
&
act
);
}
pub
fn
i18n_f
(
format
:
&
str
,
kwargs
:
&
[(
&
str
,
&
str
)])
->
String
{
let
mut
s
=
gettext
(
format
);
for
(
k
,
v
)
in
kwargs
{
...
...
src/widgets/image_page.rs
View file @
181247c0
...
...
@@ -5,7 +5,7 @@ use gtk::subclass::prelude::*;
mod
imp
{
use
super
::
*
;
use
glib
::
once_cell
::
sync
::
Lazy
;
use
glib
::{
Param
Flags
,
Param
Spec
,
ParamSpecString
,
Value
};
use
glib
::{
ParamSpec
,
ParamSpecString
,
Value
};
use
gtk
::
glib
::
once_cell
::
sync
::
OnceCell
;
use
std
::
cell
::
RefCell
;
...
...
@@ -25,7 +25,9 @@ mod imp {
}
impl
ObjectImpl
for
ImagePageWidget
{
fn
constructed
(
&
self
,
obj
:
&
Self
::
Type
)
{
fn
constructed
(
&
self
)
{
self
.parent_constructed
();
let
obj
=
self
.instance
();
let
layout_manager
=
obj
.layout_manager
()
.map
(|
l
|
l
.downcast
::
<
gtk
::
BoxLayout
>
()
.unwrap
())
...
...
@@ -81,27 +83,22 @@ mod imp {
container
.append
(
&
body_label
);
obj
.append
(
&
clamp
);
self
.parent_constructed
(
obj
);
}
fn
properties
()
->
&
'static
[
ParamSpec
]
{
static
PROPERTIES
:
Lazy
<
Vec
<
ParamSpec
>>
=
Lazy
::
new
(||
{
vec!
[
ParamSpecString
::
builder
(
"resource-uri"
)
.flags
(
ParamFlags
::
READWRITE
|
ParamFlags
::
CONSTRUCT_ONLY
)
.build
(),
ParamSpecString
::
builder
(
"head"
)
.flags
(
ParamFlags
::
READWRITE
|
ParamFlags
::
CONSTRUCT_ONLY
)
.build
(),
ParamSpecString
::
builder
(
"body"
)
.flags
(
ParamFlags
::
READWRITE
|
ParamFlags
::
CONSTRUCT
)
.construct_only
()
.build
(),
ParamSpecString
::
builder
(
"head"
)
.construct_only
()
.build
(),
ParamSpecString
::
builder
(
"body"
)
.construct
()
.build
(),
]
});
PROPERTIES
.as_ref
()
}
fn
set_property
(
&
self
,
_
obj
:
&
Self
::
Type
,
_
id
:
usize
,
value
:
&
Value
,
pspec
:
&
ParamSpec
)
{
fn
set_property
(
&
self
,
_id
:
usize
,
value
:
&
Value
,
pspec
:
&
ParamSpec
)
{
match
pspec
.name
()
{
"resource-uri"
=>
{
let
resource_uri
:
String
=
value
.get
()
.unwrap
();
...
...
@@ -121,7 +118,7 @@ mod imp {
}
}
fn
property
(
&
self
,
_
obj
:
&
Self
::
Type
,
_
id
:
usize
,
pspec
:
&
ParamSpec
)
->
Value
{
fn
property
(
&
self
,
_id
:
usize
,
pspec
:
&
ParamSpec
)
->
Value
{
match
pspec
.name
()
{
"resource-uri"
=>
self
.resource_uri
.get
()
.to_value
(),
"head"
=>
self
.head
.get
()
.to_value
(),
...
...
@@ -146,7 +143,6 @@ impl ImagePageWidget {
(
"head"
,
&
head
),
(
"body"
,
&
body
),
])
.unwrap
()
}
pub
fn
set_body
(
&
self
,
body
:
&
str
)
{
...
...
src/widgets/paginator.rs
View file @
181247c0
...
...
@@ -42,7 +42,9 @@ mod imp {
}
impl
ObjectImpl
for
PaginatorWidget
{
fn
constructed
(
&
self
,
obj
:
&
Self
::
Type
)
{
fn
constructed
(
&
self
)
{
self
.parent_constructed
();
let
obj
=
self
.instance
();
let
layout_manager
=
obj
.layout_manager
()
.map
(|
l
|
l
.downcast
::
<
gtk
::
BoxLayout
>
()
.unwrap
())
...
...
@@ -66,24 +68,17 @@ mod imp {
}));
obj
.add_controller
(
&
controller
);
self
.parent_constructed
(
obj
);
}
}
impl
WidgetImpl
for
PaginatorWidget
{}
impl
BoxImpl
for
PaginatorWidget
{}
impl
BuildableImpl
for
PaginatorWidget
{
fn
add_child
(
&
self
,
buildable
:
&
Self
::
Type
,
builder
:
&
gtk
::
Builder
,
child
:
&
glib
::
Object
,
type_
:
Option
<&
str
>
,
)
{
fn
add_child
(
&
self
,
builder
:
&
gtk
::
Builder
,
child
:
&
glib
::
Object
,
type_
:
Option
<&
str
>
)
{
if
!
self
.carousel
.is_bound
()
{
self
.parent_add_child
(
build
able
,
build
er
,
child
,
type_
);
self
.parent_add_child
(
builder
,
child
,
type_
);
}
else
{
buildable
.add_page
(
child
.clone
()
.downcast
::
<
gtk
::
Widget
>
()
.unwrap
());
self
.instance
()
.add_page
(
child
.clone
()
.downcast
::
<
gtk
::
Widget
>
()
.unwrap
());
}
}
}
...
...
@@ -97,7 +92,7 @@ glib::wrapper! {
impl
PaginatorWidget
{
pub
fn
new
()
->
Self
{
glib
::
Object
::
new
(
&
[])
.unwrap
()
glib
::
Object
::
new
(
&
[])
}
pub
fn
try_next
(
&
self
)
->
Option
<
()
>
{
...
...
src/widgets/window.rs
View file @
181247c0
...
...
@@ -37,7 +37,9 @@ mod imp {
}
impl
ObjectImpl
for
Window
{
fn
constructed
(
&
self
,
widget
:
&
Self
::
Type
)
{
fn
constructed
(
&
self
)
{
self
.parent_constructed
();
let
widget
=
self
.instance
();
widget
.set_icon_name
(
Some
(
config
::
APP_ID
));
// Devel Profile
...
...
@@ -53,7 +55,6 @@ mod imp {
&
[(
"name"
,
&
name
),
(
"version"
,
&
version
)],
);
self
.welcome_page
.set_body
(
&
body
);
self
.parent_constructed
(
widget
);
}
}
impl
WidgetImpl
for
Window
{}
...
...
@@ -70,7 +71,7 @@ glib::wrapper! {
impl
Window
{
pub
fn
new
(
app
:
&
Application
)
->
Self
{
glib
::
Object
::
new
(
&
[(
"application"
,
app
)])
.unwrap
()
glib
::
Object
::
new
(
&
[(
"application"
,
app
)])
}
pub
fn
paginator
(
&
self
)
->
PaginatorWidget
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment