1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use crate::utils::i18n_f;
use gettextrs::gettext;
use gtk::prelude::*;
use std::cell::RefCell;
use std::rc::Rc;
use super::pages::{ImagePageWidget, WelcomePageWidget};
use super::paginator::PaginatorWidget;
use crate::config::{APP_ID, PROFILE};
pub struct Window {
pub widget: libhandy::ApplicationWindow,
pub paginator: RefCell<Rc<PaginatorWidget>>,
}
impl Window {
pub fn new(app: >k::Application) -> Self {
let widget = libhandy::ApplicationWindow::new();
widget.set_application(Some(app));
let paginator = RefCell::new(PaginatorWidget::new());
let mut window_widget = Window { widget, paginator };
window_widget.init();
window_widget
}
pub fn start_tour(&self) {
self.paginator.borrow_mut().set_page(1);
}
pub fn reset_tour(&self) {
self.paginator.borrow_mut().set_page(0);
}
fn init(&mut self) {
self.widget.set_default_size(960, 720);
self.widget.set_icon_name(Some(APP_ID));
// Devel Profile
if PROFILE == "Devel" {
self.widget.get_style_context().add_class("devel");
}
self.paginator
.borrow_mut()
.add_page(WelcomePageWidget::new().widget.upcast::<gtk::Widget>());
self.paginator.borrow_mut().add_page(
ImagePageWidget::new(
"/org/gnome/Tour/overview.svg",
gettext("Get an Overview"),
gettext("Press the Super key to see open windows and apps."),
)
.widget
.upcast::<gtk::Widget>(),
);
self.paginator.borrow_mut().add_page(
ImagePageWidget::new(
"/org/gnome/Tour/search.svg",
gettext("Just Type to Search"),
gettext("Type in the overview to search. Launch apps, find things."),
)
.widget
.upcast::<gtk::Widget>(),
);
self.paginator.borrow_mut().add_page(
ImagePageWidget::new(
"/org/gnome/Tour/workspaces.svg",
gettext("Keep on Top with Workspaces"),
gettext("Easily organize windows with the workspaces view."),
)
.widget
.upcast::<gtk::Widget>(),
);
self.paginator.borrow_mut().add_page(
ImagePageWidget::new(
"/org/gnome/Tour/blank.svg",
gettext("Up/Down for the Overview"),
gettext("On a touchpad, use three-finger vertical swipes. Try it!"),
)
.widget
.upcast::<gtk::Widget>(),
);
self.paginator.borrow_mut().add_page(
ImagePageWidget::new(
"/org/gnome/Tour/blank.svg",
gettext("Left/Right for Workspaces"),
gettext("On a touchpad, use three-finger horizontal swipes. Try it!"),
)
.widget
.upcast::<gtk::Widget>(),
);
let name = glib::get_os_info("NAME").unwrap_or_else(|| "GNOME".into());
let version = glib::get_os_info("VERSION").unwrap_or_else(|| "".into());
let last_page = ImagePageWidget::new(
"/org/gnome/Tour/ready-to-go.svg",
gettext("That's it. Have a nice day!"),
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(last_page.widget.upcast::<gtk::Widget>());
self.widget.add(&self.paginator.borrow().widget);
}
}