[gnome-tour/wip/jimmac/final-page] Last page: add a specific class



commit bfed29f94b59573f111c652ac32ff829ba40c856
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Thu Jan 30 14:40:25 2020 +0100

    Last page: add a specific class

 src/widgets/pages/image.rs | 21 +++++++++++++--------
 src/widgets/window.rs      |  6 ++++--
 2 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/widgets/pages/image.rs b/src/widgets/pages/image.rs
index fe523b3..ad72878 100644
--- a/src/widgets/pages/image.rs
+++ b/src/widgets/pages/image.rs
@@ -29,7 +29,7 @@ impl Pageable for ImagePageWidget {
 
 impl ImagePageWidget {
     pub fn new(resource_uri: &str, title: String, head: String, body: String) -> Self {
-        let widget = gtk::Box::new(gtk::Orientation::Vertical, 12);
+        let widget = gtk::Box::new(gtk::Orientation::Vertical, 0);
 
         let image_page = Self {
             widget,
@@ -44,21 +44,24 @@ impl ImagePageWidget {
     }
 
     fn init(&self) {
-        self.widget.set_halign(gtk::Align::Center);
-        self.widget.set_valign(gtk::Align::Center);
-        self.widget.set_property_margin(48);
+        self.widget.set_halign(gtk::Align::Fill);
+        self.widget.set_valign(gtk::Align::Fill);
+
+        let container = gtk::Box::new(gtk::Orientation::Vertical, 12);
+        container.set_halign(gtk::Align::Center);
+        container.set_valign(gtk::Align::Center);
+        container.set_property_margin(48);
 
         let image = gtk::Picture::new_for_resource(Some(&self.resource_uri));
         image.set_valign(gtk::Align::Start);
-        self.widget.add(&image);
+        container.add(&image);
 
         let head_label = gtk::Label::new(Some(&self.get_head()));
         head_label.set_justify(gtk::Justification::Center);
         head_label.set_valign(gtk::Align::Center);
         head_label.set_margin_top(36);
         head_label.get_style_context().add_class("page-title");
-
-        self.widget.add(&head_label);
+        container.add(&head_label);
 
         let body_label = gtk::Label::new(Some(&self.get_body()));
         body_label.set_lines(2);
@@ -67,6 +70,8 @@ impl ImagePageWidget {
         body_label.set_valign(gtk::Align::Center);
         body_label.get_style_context().add_class("page-body");
         body_label.set_margin_top(12);
-        self.widget.add(&body_label);
+        container.add(&body_label);
+
+        self.widget.add(&container);
     }
 }
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index 4a8a32f..1b6444f 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -123,12 +123,14 @@ impl Window {
             gettext("The Software app makese it easy to find and install all the apps you need."),
         )));
 
-        self.paginator.add_page(Box::new(ImagePageWidget::new(
+        let last_page = ImagePageWidget::new(
             "/org/gnome/Tour/ready-to-go.svg",
             gettext("Learn More"),
             gettext("That's it! To learn more, see the Help"),
             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.container.add_named(&self.paginator.widget, "pages");
         self.widget.add(&self.container);


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