[gnome-tour/bilelmoussaoui/video: 1/2] remove uncessary title prop
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tour/bilelmoussaoui/video: 1/2] remove uncessary title prop
- Date: Fri, 7 Aug 2020 17:23:20 +0000 (UTC)
commit c02d4052fa19b2635325824af50787b7aa79df36
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Fri Aug 7 16:58:48 2020 +0200
remove uncessary title prop
src/widgets/pages/image.rs | 16 +-------
src/widgets/pages/mod.rs | 2 -
src/widgets/pages/page.rs | 4 --
src/widgets/pages/welcome.rs | 17 +--------
src/widgets/paginator.rs | 9 ++---
src/widgets/window.rs | 90 +++++++++++++++++++++++++-------------------
6 files changed, 59 insertions(+), 79 deletions(-)
---
diff --git a/src/widgets/pages/image.rs b/src/widgets/pages/image.rs
index 5986eb4..8fb73ae 100644
--- a/src/widgets/pages/image.rs
+++ b/src/widgets/pages/image.rs
@@ -1,26 +1,14 @@
-use super::page::Pageable;
use gtk::prelude::*;
pub struct ImagePageWidget {
pub widget: gtk::Box,
- pub title: String,
-}
-
-impl Pageable for ImagePageWidget {
- fn get_widget(&self) -> gtk::Widget {
- self.widget.clone().upcast::<gtk::Widget>()
- }
-
- fn get_title(&self) -> String {
- self.title.clone()
- }
}
impl ImagePageWidget {
- pub fn new(resource_uri: &str, title: String, head: String, body: String) -> Self {
+ pub fn new(resource_uri: &str, head: String, body: String) -> Self {
let widget = gtk::Box::new(gtk::Orientation::Vertical, 0);
- let image_page = Self { widget, title };
+ let image_page = Self { widget };
image_page.init(resource_uri, head, body);
image_page
diff --git a/src/widgets/pages/mod.rs b/src/widgets/pages/mod.rs
index 34b8e9c..4c7ee37 100644
--- a/src/widgets/pages/mod.rs
+++ b/src/widgets/pages/mod.rs
@@ -1,7 +1,5 @@
mod image;
-mod page;
mod welcome;
pub use image::ImagePageWidget;
-pub use page::Pageable;
pub use welcome::WelcomePageWidget;
diff --git a/src/widgets/pages/welcome.rs b/src/widgets/pages/welcome.rs
index 009d437..b645c3b 100644
--- a/src/widgets/pages/welcome.rs
+++ b/src/widgets/pages/welcome.rs
@@ -1,29 +1,14 @@
-use super::page::Pageable;
use gettextrs::gettext;
use gtk::prelude::*;
pub struct WelcomePageWidget {
pub widget: gtk::Box,
- pub title: String,
-}
-
-impl Pageable for WelcomePageWidget {
- fn get_widget(&self) -> gtk::Widget {
- self.widget.clone().upcast::<gtk::Widget>()
- }
-
- fn get_title(&self) -> String {
- self.title.clone()
- }
}
impl WelcomePageWidget {
pub fn new() -> Self {
let widget = gtk::Box::new(gtk::Orientation::Vertical, 0);
- let welcome_page = Self {
- widget,
- title: gettext("Welcome Tour"),
- };
+ let welcome_page = Self { widget };
welcome_page.init();
welcome_page
diff --git a/src/widgets/paginator.rs b/src/widgets/paginator.rs
index cf0742f..67a7d32 100644
--- a/src/widgets/paginator.rs
+++ b/src/widgets/paginator.rs
@@ -4,7 +4,6 @@ use gtk::prelude::*;
use std::cell::RefCell;
use std::rc::Rc;
-use super::pages::Pageable;
use libhandy::prelude::{CarouselExt, CarouselIndicatorDotsExt, HeaderBarExt};
pub struct PaginatorWidget {
@@ -12,7 +11,7 @@ pub struct PaginatorWidget {
carousel: libhandy::Carousel,
carousel_dots: libhandy::CarouselIndicatorDots,
headerbar: libhandy::HeaderBar,
- pages: RefCell<Vec<Box<dyn Pageable>>>,
+ pages: RefCell<Vec<gtk::Widget>>,
current_page: RefCell<u32>,
next_btn: gtk::Button,
close_btn: gtk::Button,
@@ -56,9 +55,9 @@ impl PaginatorWidget {
Ok(())
}
- pub fn add_page(&self, page: Box<dyn Pageable>) {
+ pub fn add_page(&self, page: gtk::Widget) {
let page_nr = self.pages.borrow().len();
- self.carousel.insert(&page.get_widget(), page_nr as i32);
+ self.carousel.insert(&page, page_nr as i32);
self.pages.borrow_mut().push(page);
self.update_position();
@@ -134,7 +133,7 @@ impl PaginatorWidget {
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());
+ self.carousel.scroll_to(page);
}
}
}
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index c17fb1b..1f79740 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -42,52 +42,66 @@ impl Window {
if PROFILE == "Devel" {
self.widget.get_style_context().add_class("devel");
}
- self.paginator.borrow_mut().add_page(Box::new(WelcomePageWidget::new()));
-
- self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
- "/org/gnome/Tour/activities.svg",
- gettext("Activities Overview"),
- gettext("Open Activities to launch apps"),
- gettext("The activities view can also be used to switch windows and search."),
- )));
-
- self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
- "/org/gnome/Tour/search.svg",
- gettext("Search"),
- gettext("Just type to search"),
- gettext("In the activities view, just start typing to search for apps, settings and more."),
- )));
-
- self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new(
- "/org/gnome/Tour/calendar.svg",
- gettext("Date & Time"),
- gettext("Click the time to see notifications"),
- gettext("The notifications popover also includes personal planning tools."),
- )));
-
- 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.borrow_mut().add_page(Box::new(ImagePageWidget::new(
- "/org/gnome/Tour/software.svg",
- gettext("Software"),
- gettext("Use Software to find and install apps"),
- gettext("Discover great apps through search, browsing and our recommendations."),
- )));
+ self.paginator.borrow_mut().add_page(WelcomePageWidget::new().widget.upcast::<gtk::Widget>());
+
+ self.paginator.borrow_mut().add_page(
+ ImagePageWidget::new(
+ "/org/gnome/Tour/activities.svg",
+ gettext("Open Activities to launch apps"),
+ gettext("The activities view can also be used to switch windows and search."),
+ )
+ .widget
+ .upcast::<gtk::Widget>(),
+ );
+
+ self.paginator.borrow_mut().add_page(
+ ImagePageWidget::new(
+ "/org/gnome/Tour/search.svg",
+ gettext("Just type to search"),
+ gettext("In the activities view, just start typing to search for apps, settings and more."),
+ )
+ .widget
+ .upcast::<gtk::Widget>(),
+ );
+
+ self.paginator.borrow_mut().add_page(
+ ImagePageWidget::new(
+ "/org/gnome/Tour/calendar.svg",
+ gettext("Click the time to see notifications"),
+ gettext("The notifications popover also includes personal planning tools."),
+ )
+ .widget
+ .upcast::<gtk::Widget>(),
+ );
+
+ self.paginator.borrow_mut().add_page(
+ ImagePageWidget::new(
+ "/org/gnome/Tour/status-menu.svg",
+ gettext("View system information and settings"),
+ gettext("Get an overview of the system status and quickly change settings."),
+ )
+ .widget
+ .upcast::<gtk::Widget>(),
+ );
+
+ self.paginator.borrow_mut().add_page(
+ ImagePageWidget::new(
+ "/org/gnome/Tour/software.svg",
+ gettext("Use Software to find and install apps"),
+ gettext("Discover great apps through search, browsing and our recommendations."),
+ )
+ .widget
+ .upcast::<gtk::Widget>(),
+ );
let name = glib::get_os_info("NAME").unwrap_or_else(|| "GNOME".into());
let last_page = ImagePageWidget::new(
"/org/gnome/Tour/ready-to-go.svg",
- gettext("Tour Completed"),
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");
- self.paginator.borrow_mut().add_page(Box::new(last_page));
+ self.paginator.borrow_mut().add_page(last_page.widget.upcast::<gtk::Widget>());
self.widget.add(&self.paginator.borrow().widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]