[gnome-tour/18-update-labels] update labels & set a smaller size by default



commit e5d70d9c15ff187b8b9892a48a9d9398de62ca2e
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Tue Jul 14 16:33:30 2020 +0200

    update labels & set a smaller size by default

 src/application.rs         |  3 +++
 src/utils.rs               | 13 +++++++++++++
 src/widgets/pages/image.rs |  5 ++++-
 src/widgets/window.rs      |  7 +++++--
 4 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/src/application.rs b/src/application.rs
index 8d8a003..634ff33 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -33,6 +33,7 @@ impl Application {
                 app.quit();
             }),
         );
+
         // Start Tour
         utils::action(
             &self.app,
@@ -64,6 +65,7 @@ impl Application {
                 }
             }),
         );
+
         utils::action(
             &self.app,
             "previous-page",
@@ -75,6 +77,7 @@ impl Application {
                 }
             }),
         );
+
         self.app.set_accels_for_action("app.quit", &["<primary>q"]);
     }
 
diff --git a/src/utils.rs b/src/utils.rs
index b04e30e..e47f286 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,3 +1,6 @@
+// based on https://gitlab.gnome.org/World/podcasts/-/blob/master/podcasts-gtk/src/i18n|utils.rs
+use gettextrs::gettext;
+
 pub fn action<T, F>(thing: &T, name: &str, action: F)
 where
     T: gio::ActionMapExt,
@@ -10,3 +13,13 @@ where
     // Add it to the map
     thing.add_action(&act);
 }
+
+pub fn i18n_f(format: &str, args: &[&str]) -> String {
+    let s = gettext(format);
+    let mut parts = s.split("{}");
+    let mut output = parts.next().unwrap_or("").to_string();
+    for (p, a) in parts.zip(args.iter()) {
+        output += &(a.to_string() + &p.to_string());
+    }
+    output
+}
diff --git a/src/widgets/pages/image.rs b/src/widgets/pages/image.rs
index 08dbb91..5986eb4 100644
--- a/src/widgets/pages/image.rs
+++ b/src/widgets/pages/image.rs
@@ -34,7 +34,10 @@ impl ImagePageWidget {
         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);
+        container.set_margin_bottom(48);
+        container.set_margin_top(12);
+        container.set_margin_start(12);
+        container.set_margin_end(12);
 
         let image = gtk::Image::from_resource(&resource_uri);
         image.set_valign(gtk::Align::Start);
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index eb15e91..180412e 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -1,3 +1,4 @@
+use crate::utils;
 use gettextrs::gettext;
 use gtk::prelude::*;
 use std::cell::RefCell;
@@ -34,7 +35,7 @@ impl Window {
     }
 
     fn init(&mut self) {
-        self.widget.set_default_size(920, 640);
+        self.widget.set_default_size(720, 500);
         self.widget.set_icon_name(Some(APP_ID));
 
         // Devel Profile
@@ -71,6 +72,7 @@ impl Window {
             gettext("View system information and settings"),
             gettext("Get an overview of the system status and quickly change settings."),
         )));
+
         self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
             "/org/gnome/Tour/software.svg",
             gettext("Software"),
@@ -78,10 +80,11 @@ impl Window {
             gettext("Discover great apps through search, browsing and our recommendations."),
         )));
 
+        let name = glib::get_os_info("NAME").unwrap_or("GNOME".into());
         let last_page = ImagePageWidget::new(
             "/org/gnome/Tour/ready-to-go.svg",
             gettext("Tour Completed"),
-            gettext("That's it! We hope that you enjoy NAME OF DISTRO."),
+            utils::i18n_f("That's it! We hope that you enjoy {}.", &[&name]),
             gettext("To get more advice and tips, see the Help app."),
         );
         last_page.widget.get_style_context().add_class("last-page");


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