Commit faa5f3c9 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

remove uncessary title prop

parent 298f0bfa
use super::page::Pageable;
use gtk::prelude::*; use gtk::prelude::*;
pub struct ImagePageWidget { pub struct ImagePageWidget {
pub widget: gtk::Box, 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 { 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 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.init(resource_uri, head, body);
image_page image_page
......
mod image; mod image;
mod page;
mod welcome; mod welcome;
pub use image::ImagePageWidget; pub use image::ImagePageWidget;
pub use page::Pageable;
pub use welcome::WelcomePageWidget; pub use welcome::WelcomePageWidget;
pub trait Pageable {
fn get_widget(&self) -> gtk::Widget;
fn get_title(&self) -> String;
}
use super::page::Pageable;
use gettextrs::gettext; use gettextrs::gettext;
use gtk::prelude::*; use gtk::prelude::*;
pub struct WelcomePageWidget { pub struct WelcomePageWidget {
pub widget: gtk::Box, 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 { impl WelcomePageWidget {
pub fn new() -> Self { pub fn new() -> Self {
let widget = gtk::Box::new(gtk::Orientation::Vertical, 0); let widget = gtk::Box::new(gtk::Orientation::Vertical, 0);
let welcome_page = Self { let welcome_page = Self { widget };
widget,
title: gettext("Welcome Tour"),
};
welcome_page.init(); welcome_page.init();
welcome_page welcome_page
......
...@@ -5,7 +5,6 @@ use gtk::prelude::*; ...@@ -5,7 +5,6 @@ use gtk::prelude::*;
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use super::pages::Pageable;
use libhandy::prelude::{CarouselExt, CarouselIndicatorDotsExt, HeaderBarExt}; use libhandy::prelude::{CarouselExt, CarouselIndicatorDotsExt, HeaderBarExt};
pub struct PaginatorWidget { pub struct PaginatorWidget {
...@@ -13,7 +12,7 @@ pub struct PaginatorWidget { ...@@ -13,7 +12,7 @@ pub struct PaginatorWidget {
carousel: libhandy::Carousel, carousel: libhandy::Carousel,
carousel_dots: libhandy::CarouselIndicatorDots, carousel_dots: libhandy::CarouselIndicatorDots,
headerbar: libhandy::HeaderBar, headerbar: libhandy::HeaderBar,
pages: RefCell<Vec<Box<dyn Pageable>>>, pages: RefCell<Vec<gtk::Widget>>,
current_page: RefCell<u32>, current_page: RefCell<u32>,
next_btn: gtk::Button, next_btn: gtk::Button,
close_btn: gtk::Button, close_btn: gtk::Button,
...@@ -57,9 +56,9 @@ impl PaginatorWidget { ...@@ -57,9 +56,9 @@ impl PaginatorWidget {
Ok(()) 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(); 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.pages.borrow_mut().push(page);
self.update_position(); self.update_position();
...@@ -135,7 +134,7 @@ impl PaginatorWidget { ...@@ -135,7 +134,7 @@ impl PaginatorWidget {
if page_nr < self.carousel.get_n_pages() { if page_nr < self.carousel.get_n_pages() {
let pages = &self.pages.borrow(); let pages = &self.pages.borrow();
let page = pages.get(page_nr as usize).unwrap(); let page = pages.get(page_nr as usize).unwrap();
self.carousel.scroll_to(&page.get_widget()); self.carousel.scroll_to(page);
} }
} }
} }
...@@ -42,52 +42,66 @@ impl Window { ...@@ -42,52 +42,66 @@ impl Window {
if PROFILE == "Devel" { if PROFILE == "Devel" {
self.widget.get_style_context().add_class("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(WelcomePageWidget::new().widget.upcast::<gtk::Widget>());
self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new( self.paginator.borrow_mut().add_page(
"/org/gnome/Tour/activities.svg", ImagePageWidget::new(
gettext("Activities Overview"), "/org/gnome/Tour/activities.svg",
gettext("Open Activities to launch apps"), gettext("Open Activities to launch apps"),
gettext("The activities view can also be used to switch windows and search."), gettext("The activities view can also be used to switch windows and search."),
))); )
.widget
self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new( .upcast::<gtk::Widget>(),
"/org/gnome/Tour/search.svg", );
gettext("Search"),
gettext("Just type to search"), self.paginator.borrow_mut().add_page(
gettext("In the activities view, just start typing to search for apps, settings and more."), ImagePageWidget::new(
))); "/org/gnome/Tour/search.svg",
gettext("Just type to search"),
self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new( gettext("In the activities view, just start typing to search for apps, settings and more."),
"/org/gnome/Tour/calendar.svg", )
gettext("Date & Time"), .widget
gettext("Click the time to see notifications"), .upcast::<gtk::Widget>(),
gettext("The notifications popover also includes personal planning tools."), );
)));
self.paginator.borrow_mut().add_page(
self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new( ImagePageWidget::new(
"/org/gnome/Tour/status-menu.svg", "/org/gnome/Tour/calendar.svg",
gettext("System Menu"), gettext("Click the time to see notifications"),
gettext("View system information and settings"), gettext("The notifications popover also includes personal planning tools."),
gettext("Get an overview of the system status and quickly change settings."), )
))); .widget
.upcast::<gtk::Widget>(),
self.paginator.borrow_mut().add_page(Box::new(ImagePageWidget::new( );
"/org/gnome/Tour/software.svg",
gettext("Software"), self.paginator.borrow_mut().add_page(
gettext("Use Software to find and install apps"), ImagePageWidget::new(
gettext("Discover great apps through search, browsing and our recommendations."), "/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 name = glib::get_os_info("NAME").unwrap_or_else(|| "GNOME".into());
let last_page = ImagePageWidget::new( let last_page = ImagePageWidget::new(
"/org/gnome/Tour/ready-to-go.svg", "/org/gnome/Tour/ready-to-go.svg",
gettext("Tour Completed"),
utils::i18n_f("That's it! We hope that you enjoy {}.", &[&name]), utils::i18n_f("That's it! We hope that you enjoy {}.", &[&name]),
gettext("To get more advice and tips, see the Help app."), gettext("To get more advice and tips, see the Help app."),
); );
last_page.widget.get_style_context().add_class("last-page"); 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); self.widget.add(&self.paginator.borrow().widget);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment