Commit faa5f3c9 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

remove uncessary title prop

parent 298f0bfa
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
......
mod image;
mod page;
mod welcome;
pub use image::ImagePageWidget;
pub use page::Pageable;
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 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
......
......@@ -5,7 +5,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 {
......@@ -13,7 +12,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,
......@@ -57,9 +56,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();
......@@ -135,7 +134,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);
}
}
}
......@@ -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);
}
......
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