[gnome-tour] use hdy Deck/Carousel to simplify the code



commit 4a1a7b180508a89f466833efdb3e743ccb0fccb2
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Sun Jul 12 01:31:43 2020 +0200

    use hdy Deck/Carousel to simplify the code

 Cargo.lock                         | 153 +++++++++++++++++++++++++++++++++----
 Cargo.toml                         |   5 +-
 build-aux/org.gnome.TourDevel.json |  28 ++++++-
 src/application.rs                 |   8 +-
 src/main.rs                        |   1 +
 src/meson.build                    |   1 -
 src/widgets/headerbar.rs           |  78 -------------------
 src/widgets/mod.rs                 |   1 -
 src/widgets/pages/welcome.rs       |  28 +++++--
 src/widgets/paginator.rs           | 118 ++++++++++++++++++----------
 src/widgets/window.rs              |  93 ++++++++--------------
 11 files changed, 300 insertions(+), 214 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index 262c99a..f3e38eb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -19,7 +19,7 @@ version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
  "atk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "gobject-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -37,9 +37,19 @@ dependencies = [
  "system-deps 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "bitflags"
-version = "1.1.0"
+version = "1.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
 [[package]]
@@ -47,7 +57,7 @@ name = "cairo-rs"
 version = "0.9.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cairo-sys-rs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -81,6 +91,18 @@ name = "either"
 version = "1.5.3"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
+[[package]]
+name = "env_logger"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "futures"
 version = "0.3.5"
@@ -172,7 +194,7 @@ name = "gdk"
 version = "0.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cairo-rs 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cairo-sys-rs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "gdk-pixbuf 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -250,7 +272,7 @@ name = "gio"
 version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -281,7 +303,7 @@ name = "glib"
 version = "0.10.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "futures-executor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -322,12 +344,15 @@ dependencies = [
 name = "gnome-tour"
 version = "0.0.1"
 dependencies = [
+ "anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
  "gdk 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "gettext-rs 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "gio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "gtk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libhandy 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pretty_env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -346,7 +371,7 @@ version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
  "atk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cairo-rs 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cairo-sys-rs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -392,6 +417,22 @@ dependencies = [
  "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "hermit-abi"
+version = "0.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "humantime"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "itertools"
 version = "0.9.0"
@@ -402,7 +443,7 @@ dependencies = [
 
 [[package]]
 name = "lazy_static"
-version = "1.3.0"
+version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
 [[package]]
@@ -410,19 +451,59 @@ name = "libc"
 version = "0.2.59"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
+[[package]]
+name = "libhandy"
+version = "1.0.0"
+source = "git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git#8e83a51344d981f0cdb6a643ae3b6fc63b328d96";
+dependencies = [
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gdk 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gdk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gio-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glib 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glib-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gobject-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gtk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gtk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libhandy-sys 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)",
+ "pango 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "libhandy-sys"
+version = "1.0.0"
+source = "git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git#8e83a51344d981f0cdb6a643ae3b6fc63b328d96";
+dependencies = [
+ "gdk 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gdk-pixbuf-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gdk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gio-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glib-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gobject-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gtk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pango-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "system-deps 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "locale_config"
 version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "log"
-version = "0.4.7"
+version = "0.4.8"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
  "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -443,7 +524,7 @@ name = "pango"
 version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "glib-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "gobject-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -491,6 +572,15 @@ name = "pkg-config"
 version = "0.3.14"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
+[[package]]
+name = "pretty_env_logger"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "proc-macro-crate"
 version = "0.1.5"
@@ -546,6 +636,11 @@ dependencies = [
  "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "quick-error"
+version = "1.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+
 [[package]]
 name = "quote"
 version = "1.0.2"
@@ -634,6 +729,14 @@ dependencies = [
  "version-compare 0.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "termcolor"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "thiserror"
 version = "1.0.20"
@@ -657,7 +760,7 @@ name = "thread_local"
 version = "0.3.6"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
- "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -712,6 +815,14 @@ name = "winapi-i686-pc-windows-gnu"
 version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 
+[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+dependencies = [
+ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "winapi-x86_64-pc-windows-gnu"
 version = "0.4.0"
@@ -722,12 +833,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 "checksum anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = 
"85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f"
 "checksum atk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"812b4911e210bd51b24596244523c856ca749e6223c50a7fbbba3f89ee37c426"
 "checksum atk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"f530e4af131d94cc4fa15c5c9d0348f0ef28bac64ba660b6b2a1cf2605dedfce"
-"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
+"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = 
"d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
 "checksum cairo-rs 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"c5c0f2e047e8ca53d0ff249c54ae047931d7a6ebe05d00af73e0ffeb6e34bdb8"
 "checksum cairo-sys-rs 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"2ed2639b9ad5f1d6efa76de95558e11339e7318426d84ac4890b86c03e828ca7"
 "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = 
"39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d"
 "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = 
"b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
 "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = 
"bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
+"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
 "checksum futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = 
"1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613"
 "checksum futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = 
"f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5"
 "checksum futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = 
"59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399"
@@ -752,11 +865,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 "checksum gtk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"3adf6adf7ba686d5e4f4dae32edfa12118af9469f67425f0afd075bf4a58ea9d"
 "checksum gtk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"89acda6f084863307d948ba64a4b1ef674e8527dddab147ee4cdcc194c880457"
 "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
+"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = 
"3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
+"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
 "checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
-"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
+"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 "checksum libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = 
"3262021842bf00fe07dbd6cf34ff25c99d7a7ebef8deea84db72be3ea3bb0aff"
+"checksum libhandy 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)" = "<none>"
+"checksum libhandy-sys 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)" = "<none>"
 "checksum locale_config 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = 
"73ac19ebe45489e5d53b4346d8b90bb3dd03275c5fdf2ce22a982516d86b535c"
-"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = 
"c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3"
+"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = 
"14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
 "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
 "checksum once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
 "checksum pango 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"460dbe5ad850c46780ba61f142e966beacf5eebb09822830f796c91d7d4fec31"
@@ -765,12 +882,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 "checksum pin-project-internal 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = 
"6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7"
 "checksum pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
 "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = 
"676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
+"checksum pretty_env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d"
 "checksum proc-macro-crate 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = 
"1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
 "checksum proc-macro-error 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = 
"fc175e9777c3116627248584e8f8b3e2987405cabe1c0adf7d1dd28f09dc7880"
 "checksum proc-macro-error-attr 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = 
"3cc9795ca17eb581285ec44936da7fc2335a3f34f2ddd13118b6f4d515435c50"
 "checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = 
"ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
 "checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = 
"369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e"
 "checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = 
"0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc"
+"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = 
"a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
 "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = 
"053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
 "checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = 
"d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad"
 "checksum regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = 
"9b01330cce219c1c6b2e209e5ed64ccd587ae5c67bed91c0b49eecf02ae40e21"
@@ -781,6 +900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 "checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = 
"1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8"
 "checksum syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a"
 "checksum system-deps 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = 
"0f3ecc17269a19353b3558b313bba738b25d82993e30d62a18406a24aba4649b"
+"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
 "checksum thiserror 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = 
"7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08"
 "checksum thiserror-impl 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = 
"bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
 "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = 
"c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
@@ -793,4 +913,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 "checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = 
"b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
 "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = 
"f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+"checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = 
"70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/Cargo.toml b/Cargo.toml
index 66838de..b9870a4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,4 +10,7 @@ gdk = "0.13"
 gtk = { version = "0.9", features= ["v3_16"] }
 gio = "0.9"
 log = "0.4"
-gettext-rs= { version = "0.4", features = ["gettext-system"] }
+gettext-rs = { version = "0.4", features = ["gettext-system"] }
+libhandy = { git = "https://gitlab.gnome.org/World/Rust/libhandy-rs.git"; }
+pretty_env_logger = "0.4"
+anyhow = "1.0"
diff --git a/build-aux/org.gnome.TourDevel.json b/build-aux/org.gnome.TourDevel.json
index 9bc0cd7..b34098d 100644
--- a/build-aux/org.gnome.TourDevel.json
+++ b/build-aux/org.gnome.TourDevel.json
@@ -14,7 +14,11 @@
         "--share=ipc",
         "--socket=fallback-x11",
         "--socket=wayland",
-        "--device=dri"
+        "--device=dri",
+        "--filesystem=xdg-run/dconf",
+        "--filesystem=~/.config/dconf:ro",
+        "--talk-name=ca.desrt.dconf",
+        "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
     ],
     "build-options" : {
         "append-path" : "/usr/lib/sdk/rust-stable/bin",
@@ -26,7 +30,27 @@
             "RUST_BACKTRACE" : "1"
         }
     },
-    "modules" : [
+    "modules" : [{
+            "name": "libhandy",
+            "buildsystem": "meson",
+            "config-opts": [
+                "-Dintrospection=disabled",
+                "-Dgtk_doc=false",
+                "-Dtests=false",
+                "-Dexamples=false",
+                "-Dvapi=false",
+                "-Dglade_catalog=disabled"
+            ],
+            "cleanup": [
+                "/include",
+                "/lib/pkgconfig"
+            ],
+            "sources": [{
+                "type": "git",
+                "url": "https://gitlab.gnome.org/GNOME/libhandy.git";,
+                "branch": "0.83.0"
+            }]
+        },
         {
             "name" : "gnome-tour",
             "buildsystem" : "meson",
diff --git a/src/application.rs b/src/application.rs
index d666ed0..2461129 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -58,7 +58,9 @@ impl Application {
             "next-page",
             clone!(@strong application => move |_, _| {
                 if let Some(window) = &*application.window.borrow().clone() {
-                    window.next_page();
+                    if window.paginator.borrow_mut().next().is_err() {
+                        window.widget.close();
+                    }
                 }
             }),
         );
@@ -67,7 +69,9 @@ impl Application {
             "previous-page",
             clone!(@strong application => move |_, _| {
                 if let Some(window) = &*application.window.borrow().clone() {
-                    window.previous_page();
+                    if window.paginator.borrow_mut().previous().is_err() {
+                        window.stop_tour();
+                    }
                 }
             }),
         );
diff --git a/src/main.rs b/src/main.rs
index ba795a3..67b3384 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,7 @@ use application::Application;
 use config::{GETTEXT_PACKAGE, LOCALEDIR};
 
 fn main() {
+    pretty_env_logger::init();
     // Prepare i18n
     setlocale(LocaleCategory::LcAll, "");
     bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
diff --git a/src/meson.build b/src/meson.build
index 3763e74..33879a0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -39,7 +39,6 @@ sources = files(
   'widgets/pages/image.rs',
   'widgets/pages/mod.rs',
   'widgets/pages/welcome.rs',
-  'widgets/headerbar.rs',
   'widgets/mod.rs',
   'widgets/paginator.rs',
   'widgets/window.rs',
diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs
index 6abdb9c..c58dca4 100644
--- a/src/widgets/mod.rs
+++ b/src/widgets/mod.rs
@@ -1,4 +1,3 @@
-mod headerbar;
 mod pages;
 mod paginator;
 mod window;
diff --git a/src/widgets/pages/welcome.rs b/src/widgets/pages/welcome.rs
index aff9af4..a61ae2c 100644
--- a/src/widgets/pages/welcome.rs
+++ b/src/widgets/pages/welcome.rs
@@ -1,5 +1,6 @@
 use gettextrs::gettext;
 use gtk::prelude::*;
+use libhandy::prelude::HeaderBarExt;
 
 pub struct WelcomePageWidget {
     pub widget: gtk::Box,
@@ -16,10 +17,14 @@ impl WelcomePageWidget {
     }
 
     fn init(&self) {
-        self.widget.set_valign(gtk::Align::Center);
-        self.widget.set_halign(gtk::Align::Center);
-        self.widget.set_margin_top(24);
-        self.widget.set_margin_bottom(24);
+        self.widget.set_property_expand(true);
+
+        let container = gtk::Box::new(gtk::Orientation::Vertical, 0);
+        container.set_property_expand(true);
+        container.set_valign(gtk::Align::Center);
+        container.set_halign(gtk::Align::Center);
+        container.set_margin_top(24);
+        container.set_margin_bottom(24);
 
         let name = glib::get_os_info("NAME").unwrap_or("GNOME".into());
         let version = glib::get_os_info("VERSION").unwrap_or("3.36".into());
@@ -27,17 +32,17 @@ impl WelcomePageWidget {
 
         let logo = gtk::Image::from_icon_name(Some(&icon), gtk::IconSize::Dialog);
         logo.set_pixel_size(196);
-        self.widget.add(&logo);
+        container.add(&logo);
 
         let title = gtk::Label::new(Some(&gettext(format!("Welcome to {} {}", name, version))));
         title.set_margin_top(36);
         title.get_style_context().add_class("large-title");
-        self.widget.add(&title);
+        container.add(&title);
 
         let text = gtk::Label::new(Some(&gettext("Hi there! If you are new to GNOME, you can take the tour 
to learn some essential features.")));
         text.get_style_context().add_class("body");
         text.set_margin_top(12);
-        self.widget.add(&text);
+        container.add(&text);
 
         let actions_container = gtk::Box::new(gtk::Orientation::Horizontal, 12);
         actions_container.set_halign(gtk::Align::Center);
@@ -60,6 +65,13 @@ impl WelcomePageWidget {
         actions_container.add(&start_tour_btn);
         actions_container.set_focus_child(Some(&start_tour_btn));
 
-        self.widget.add(&actions_container);
+        container.add(&actions_container);
+
+        let headerbar = libhandy::HeaderBar::new();
+        headerbar.set_show_close_button(true);
+        headerbar.set_title(Some(&gettext("Welcome Tour")));
+
+        self.widget.add(&headerbar);
+        self.widget.add(&container);
     }
 }
diff --git a/src/widgets/paginator.rs b/src/widgets/paginator.rs
index 7cb067d..49fd724 100644
--- a/src/widgets/paginator.rs
+++ b/src/widgets/paginator.rs
@@ -1,71 +1,105 @@
+use anyhow::Result;
+use gettextrs::gettext;
 use gtk::prelude::*;
 use std::cell::RefCell;
-use std::convert::TryInto;
+use std::rc::Rc;
 
 use super::pages::Pageable;
+use libhandy::prelude::{CarouselExt, HeaderBarExt};
 
 pub struct PaginatorWidget {
-    pub widget: gtk::Stack,
-    pages: Vec<Box<dyn Pageable>>,
-    current_page: RefCell<i32>,
+    pub widget: gtk::Box,
+    carousel: libhandy::Carousel,
+    headerbar: libhandy::HeaderBar,
+    pages: RefCell<Vec<Box<dyn Pageable>>>,
+    current_page: RefCell<u32>,
+    next_btn: gtk::Button,
 }
 
 impl PaginatorWidget {
-    pub fn new() -> Self {
-        let widget = gtk::Stack::new();
+    pub fn new() -> Rc<Self> {
+        let widget = gtk::Box::new(gtk::Orientation::Vertical, 0);
 
-        let paginator = Self {
+        let paginator = Rc::new(Self {
             widget,
-            pages: Vec::new(),
-            current_page: RefCell::new(1),
-        };
-        paginator.init();
+            carousel: libhandy::Carousel::new(),
+            headerbar: libhandy::HeaderBar::new(),
+            next_btn: gtk::Button::new(),
+            pages: RefCell::new(Vec::new()),
+            current_page: RefCell::new(0),
+        });
+        paginator.init(paginator.clone());
         paginator
     }
 
-    pub fn get_total_pages(&self) -> i32 {
-        self.pages.len().try_into().unwrap_or(1)
+    pub fn next(&self) -> Result<()> {
+        let p = *self.current_page.borrow() + 1;
+        if p == self.carousel.get_n_pages() {
+            anyhow::bail!("Already at the latest page");
+        }
+        self.set_page(p);
+        Ok(())
     }
 
-    pub fn get_current_page_nr(&self) -> i32 {
-        *self.current_page.borrow()
+    pub fn previous(&self) -> Result<()> {
+        let p = *self.current_page.borrow();
+        if p == 0 {
+            anyhow::bail!("Already at the first page");
+        }
+        self.set_page(p - 1);
+        Ok(())
     }
 
-    pub fn get_current_page(&self) -> Option<&Box<dyn Pageable>> {
-        let current_page_idx: usize = (self.get_current_page_nr() - 1).try_into().unwrap_or(0);
-        self.pages.get(current_page_idx)
+    pub fn add_page(&self, page: Box<dyn Pageable>) {
+        let page_nr = self.pages.borrow().len();
+        self.carousel.insert(&page.get_widget(), page_nr as i32);
+        self.pages.borrow_mut().push(page);
     }
 
-    pub fn next(&self) {
-        let next_page = *self.current_page.borrow() + 1;
-        self.go_to(next_page);
-    }
+    fn init(&self, p: Rc<Self>) {
+        self.carousel.set_property_expand(true);
+        self.carousel.set_animation_duration(300);
 
-    pub fn previous(&self) {
-        let previous_page = *self.current_page.borrow() - 1;
-        self.go_to(previous_page);
-    }
+        self.carousel.connect_page_changed(clone!(@weak p => move |carousel, page_nr| {
+            let pages = &p.pages.borrow();
+            let page = pages.get(page_nr as usize).unwrap();
+            p.headerbar.set_title(Some(&page.get_title()));
 
-    pub fn add_page(&mut self, page: Box<dyn Pageable>) {
-        let page_nr = self.pages.len() + 1;
-        let page_name = format!("page-{}", page_nr);
+            if page_nr == carousel.get_n_pages() - 1 {
+                p.next_btn.set_label(&gettext("Close"));
+            } else {
+                p.next_btn.set_label(&gettext("Next"));
+            }
+            p.current_page.replace(page_nr);
+        }));
 
-        self.widget.add_named(&page.get_widget(), &page_name);
-        self.pages.push(page);
-    }
+        let previous_btn = gtk::Button::new();
+        previous_btn.add(&gtk::Label::new(Some("Previous")));
+        previous_btn.set_halign(gtk::Align::Start);
+        previous_btn.set_action_name(Some("app.previous-page"));
+        previous_btn.set_hexpand(true);
+        previous_btn.set_property_width_request(60);
 
-    fn init(&self) {
-        self.widget.set_transition_type(gtk::StackTransitionType::SlideLeftRight);
-        self.widget.set_transition_duration(300);
-    }
+        self.next_btn.add(&gtk::Label::new(Some(&gettext("Next"))));
+        self.next_btn.get_style_context().add_class("suggested-action");
+        self.next_btn.set_action_name(Some("app.next-page"));
+        self.next_btn.set_halign(gtk::Align::End);
+        self.next_btn.set_hexpand(true);
+        self.next_btn.set_property_width_request(60);
 
-    fn go_to(&self, page_nr: i32) {
-        let page_name = format!("page-{}", page_nr);
-        let total_pages: i32 = self.pages.len().try_into().unwrap_or(0);
+        self.headerbar.pack_start(&previous_btn);
+        self.headerbar.pack_end(&self.next_btn);
+        self.headerbar.set_show_close_button(false);
+
+        self.widget.add(&self.headerbar);
+        self.widget.add(&self.carousel);
+    }
 
-        if page_nr <= total_pages && self.widget.get_child_by_name(&page_name).is_some() {
-            self.current_page.replace(page_nr);
-            self.widget.set_visible_child_name(&page_name);
+    pub fn set_page(&self, page_nr: u32) {
+        if page_nr < self.carousel.get_n_pages() {
+            let pages = &self.pages.borrow();
+            let page = pages.get(page_nr as usize).unwrap();
+            self.carousel.scroll_to(&page.get_widget());
         }
     }
 }
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index 4ac19fc..8efbe7f 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -1,29 +1,32 @@
 use gettextrs::gettext;
 use gtk::prelude::*;
+use std::cell::RefCell;
+use std::rc::Rc;
 
-use super::headerbar::HeaderBar;
 use super::pages::{ImagePageWidget, WelcomePageWidget};
 use super::paginator::PaginatorWidget;
 use crate::config::PROFILE;
+use libhandy::prelude::DeckExt;
 
 pub struct Window {
-    pub widget: gtk::ApplicationWindow,
-    container: gtk::Stack,
-    headerbar: HeaderBar,
-    paginator: PaginatorWidget,
+    pub widget: libhandy::ApplicationWindow,
+    deck: libhandy::Deck,
+    pub paginator: RefCell<Rc<PaginatorWidget>>,
+    welcome_page: WelcomePageWidget,
 }
 
 impl Window {
     pub fn new(app: &gtk::Application) -> Self {
-        let widget = gtk::ApplicationWindow::new(app);
-        let container = gtk::Stack::new();
-        let headerbar = HeaderBar::new();
-        let paginator = PaginatorWidget::new();
+        let widget = libhandy::ApplicationWindow::new();
+        widget.set_application(Some(app));
+
+        let deck = libhandy::Deck::new();
+        let paginator = RefCell::new(PaginatorWidget::new());
 
         let mut window_widget = Window {
             widget,
-            container,
-            headerbar,
+            deck,
+            welcome_page: WelcomePageWidget::new(),
             paginator,
         };
 
@@ -32,91 +35,55 @@ impl Window {
     }
 
     pub fn start_tour(&self) {
-        if let Some(page) = self.paginator.get_current_page() {
-            self.headerbar.set_page_title(&page.get_title());
-        }
-        self.container.set_visible_child_name("pages");
-        self.headerbar.start_tour();
-    }
-
-    fn end_tour(&self) {
-        self.container.set_visible_child_name("welcome");
-        self.headerbar.end_tour();
-    }
-
-    pub fn next_page(&self) {
-        let total_pages = self.paginator.get_total_pages();
-        let current_page = self.paginator.get_current_page_nr();
-        self.headerbar.set_page_nr(current_page + 1, total_pages);
-
-        if current_page == total_pages {
-            self.widget.close();
-        } else {
-            self.paginator.next();
-        }
-        if let Some(page) = self.paginator.get_current_page() {
-            self.headerbar.set_page_title(&page.get_title());
-        }
+        self.deck.set_visible_child(&self.paginator.borrow().widget);
+        self.paginator.borrow_mut().set_page(0);
     }
 
-    pub fn previous_page(&self) {
-        let total_pages = self.paginator.get_total_pages();
-        let current_page = self.paginator.get_current_page_nr();
-        self.headerbar.set_page_nr(current_page - 1, total_pages);
-
-        match current_page {
-            1 => self.end_tour(),
-            _ => self.paginator.previous(),
-        }
-
-        if let Some(page) = self.paginator.get_current_page() {
-            self.headerbar.set_page_title(&page.get_title());
-        }
+    pub fn stop_tour(&self) {
+        self.paginator.borrow_mut().set_page(0);
+        self.deck.set_visible_child(&self.welcome_page.widget);
     }
 
     fn init(&mut self) {
         self.widget.set_default_size(920, 640);
-        self.container.set_transition_type(gtk::StackTransitionType::SlideLeftRight);
-        self.container.set_transition_duration(300);
+        self.deck.set_transition_type(libhandy::DeckTransitionType::Slide);
+        self.deck.set_transition_duration(300);
 
         // Devel Profile
         if PROFILE == "Devel" {
             self.widget.get_style_context().add_class("devel");
         }
 
-        self.widget.set_titlebar(Some(&self.headerbar.widget));
-
-        let welcome_page = WelcomePageWidget::new();
-        self.container.add_named(&welcome_page.widget, "welcome");
+        self.deck.add(&self.welcome_page.widget);
 
-        self.paginator.add_page(Box::new(ImagePageWidget::new(
+        self.paginator.borrow().add_page(Box::new(ImagePageWidget::new(
             "/org/gnome/Tour/activities.svg",
             gettext("Activities Overview"),
             gettext("Open Activities to start apps"),
             gettext("You can also view open windows, search and use workspaces."),
         )));
 
-        self.paginator.add_page(Box::new(ImagePageWidget::new(
+        self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
             "/org/gnome/Tour/search.svg",
             gettext("Search"),
             gettext("In the Activities Overview, just start typing to search"),
             gettext("Search can be used to launch apps, find settings, do calculations and much more."),
         )));
 
-        self.paginator.add_page(Box::new(ImagePageWidget::new(
+        self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
             "/org/gnome/Tour/calendar.svg",
             gettext("Date & Time"),
             gettext("Click the time to see your now and next"),
             gettext("This includes notifications, media controls, calendar events, the weather and world 
clocks."),
         )));
 
-        self.paginator.add_page(Box::new(ImagePageWidget::new(
+        self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
             "/org/gnome/Tour/status-menu.svg",
             gettext("System Menu"),
             gettext("View system information and settings"),
             gettext("Get an overview of the system status and quickly change settings."),
         )));
-        self.paginator.add_page(Box::new(ImagePageWidget::new(
+        self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
             "/org/gnome/Tour/software.svg",
             gettext("Software"),
             gettext("Find and install apps"),
@@ -130,9 +97,9 @@ impl Window {
             gettext("The help app contains information, tips and tricks."),
         );
         last_page.widget.get_style_context().add_class("last-page");
-        self.paginator.add_page(Box::new(last_page));
+        self.paginator.borrow_mut().add_page(Box::new(last_page));
 
-        self.container.add_named(&self.paginator.widget, "pages");
-        self.widget.add(&self.container);
+        self.deck.add(&self.paginator.borrow().widget);
+        self.widget.add(&self.deck);
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]