Commit 80e64abe authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

replace next with start on the first page

parent 9c7abe83
...@@ -14,6 +14,7 @@ pub struct PaginatorWidget { ...@@ -14,6 +14,7 @@ pub struct PaginatorWidget {
pages: RefCell<Vec<gtk::Widget>>, pages: RefCell<Vec<gtk::Widget>>,
current_page: RefCell<u32>, current_page: RefCell<u32>,
next_btn: gtk::Button, next_btn: gtk::Button,
start_btn: gtk::Button,
finish_btn: gtk::Button, finish_btn: gtk::Button,
close_btn: gtk::Button, close_btn: gtk::Button,
previous_btn: gtk::Button, previous_btn: gtk::Button,
...@@ -28,6 +29,7 @@ impl PaginatorWidget { ...@@ -28,6 +29,7 @@ impl PaginatorWidget {
carousel: libhandy::Carousel::new(), carousel: libhandy::Carousel::new(),
carousel_dots: libhandy::CarouselIndicatorDots::new(), carousel_dots: libhandy::CarouselIndicatorDots::new(),
headerbar: libhandy::HeaderBar::new(), headerbar: libhandy::HeaderBar::new(),
start_btn: gtk::Button::with_label(&gettext("_Start")),
next_btn: gtk::Button::with_label(&gettext("_Next")), next_btn: gtk::Button::with_label(&gettext("_Next")),
finish_btn: gtk::Button::with_label(&gettext("_Close")), finish_btn: gtk::Button::with_label(&gettext("_Close")),
close_btn: gtk::Button::with_label(&gettext("_Close")), close_btn: gtk::Button::with_label(&gettext("_Close")),
...@@ -73,16 +75,23 @@ impl PaginatorWidget { ...@@ -73,16 +75,23 @@ impl PaginatorWidget {
let forelast_page = n_pages - 2.0; let forelast_page = n_pages - 2.0;
let last_page = n_pages - 1.0; let last_page = n_pages - 1.0;
let (opacity_finish, opacity_previous) = if (0.0 <= position) && (position < 1.0) { let (opacity_finish, opacity_previous, opacity_start, opacity_next) =
(0.0, position) if (0.0 <= position) && (position < 1.0) {
(0.0, position, 1.0, position)
} else if (0.0 <= position) && (position <= forelast_page) { } else if (0.0 <= position) && (position <= forelast_page) {
(0.0, 1.0) (0.0, 1.0, 1f64 - position, 1.0)
} else if (forelast_page < position) && (position <= last_page) { } else if (forelast_page < position) && (position <= last_page) {
(position - forelast_page, 1.0) (position - forelast_page, 1.0, 0.0, 1.0)
} else { } else {
panic!("Position of the carousel is outside the allowed range"); panic!("Position of the carousel is outside the allowed range");
}; };
self.start_btn.set_opacity(opacity_start);
self.start_btn.set_visible(opacity_start > 0_f64);
self.next_btn.set_opacity(opacity_next);
self.next_btn.set_visible(opacity_next > 0_f64);
self.finish_btn.set_opacity(opacity_finish); self.finish_btn.set_opacity(opacity_finish);
self.finish_btn.set_visible(opacity_finish > 0_f64); self.finish_btn.set_visible(opacity_finish > 0_f64);
...@@ -103,13 +112,18 @@ impl PaginatorWidget { ...@@ -103,13 +112,18 @@ impl PaginatorWidget {
.connect_property_position_notify(clone!(@weak p => move |_| { .connect_property_position_notify(clone!(@weak p => move |_| {
p.update_position(); p.update_position();
})); }));
self.start_btn
.get_style_context()
.add_class("suggested-action");
self.start_btn.set_use_underline(true);
self.start_btn.set_action_name(Some("app.start-tour"));
self.start_btn.show();
self.next_btn self.next_btn
.get_style_context() .get_style_context()
.add_class("suggested-action"); .add_class("suggested-action");
self.next_btn.set_use_underline(true); self.next_btn.set_use_underline(true);
self.next_btn.set_action_name(Some("app.next-page")); self.next_btn.set_action_name(Some("app.next-page"));
self.next_btn.show();
self.close_btn.set_use_underline(true); self.close_btn.set_use_underline(true);
self.close_btn.set_action_name(Some("app.quit")); self.close_btn.set_action_name(Some("app.quit"));
...@@ -134,15 +148,21 @@ impl PaginatorWidget { ...@@ -134,15 +148,21 @@ impl PaginatorWidget {
next_overlay.add_overlay(&self.finish_btn); next_overlay.add_overlay(&self.finish_btn);
next_overlay.show(); next_overlay.show();
let start_overlay = gtk::Overlay::new();
start_overlay.add(&self.start_btn);
start_overlay.add_overlay(&next_overlay);
start_overlay.show();
let btn_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Horizontal); let btn_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Horizontal);
btn_size_group.add_widget(&self.previous_btn); btn_size_group.add_widget(&self.previous_btn);
btn_size_group.add_widget(&self.close_btn); btn_size_group.add_widget(&self.close_btn);
btn_size_group.add_widget(&self.next_btn); btn_size_group.add_widget(&next_overlay);
btn_size_group.add_widget(&start_overlay);
btn_size_group.add_widget(&self.finish_btn); btn_size_group.add_widget(&self.finish_btn);
self.headerbar.set_custom_title(Some(&self.carousel_dots)); self.headerbar.set_custom_title(Some(&self.carousel_dots));
self.headerbar.pack_start(&previous_overlay); self.headerbar.pack_start(&previous_overlay);
self.headerbar.pack_end(&next_overlay); self.headerbar.pack_end(&start_overlay);
self.headerbar.set_show_close_button(false); self.headerbar.set_show_close_button(false);
self.headerbar.show(); self.headerbar.show();
......
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