Commit 6926f744 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

welcome page: always how a headerbar

fixes #30
parent 241993e7
......@@ -167,41 +167,6 @@ impl WelcomePageWidget {
text.show();
container.add(&text);
let actions_container = gtk::BoxBuilder::new()
.orientation(gtk::Orientation::Horizontal)
.spacing(12)
.halign(gtk::Align::Center)
.margin_top(36)
.build();
let skip_tour_btn = gtk::ButtonBuilder::new()
.label(&gettext("_No Thanks"))
.height_request(40)
.width_request(180)
.use_underline(true)
.action_name("app.skip-tour")
.build();
skip_tour_btn.show();
actions_container.add(&skip_tour_btn);
let start_tour_btn = gtk::ButtonBuilder::new()
.label(&gettext("_Start Tour"))
.height_request(40)
.width_request(180)
.use_underline(true)
.action_name("app.start-tour")
.build();
start_tour_btn
.get_style_context()
.add_class("suggested-action");
start_tour_btn.show();
actions_container.add(&start_tour_btn);
actions_container.set_focus_child(Some(&start_tour_btn));
actions_container.show();
container.add(&actions_container);
container.show();
self.widget.add(&container);
self.widget.show();
......
......@@ -14,6 +14,7 @@ pub struct PaginatorWidget {
pages: RefCell<Vec<gtk::Widget>>,
current_page: RefCell<u32>,
next_btn: gtk::Button,
finish_btn: gtk::Button,
close_btn: gtk::Button,
previous_btn: gtk::Button,
}
......@@ -28,6 +29,7 @@ impl PaginatorWidget {
carousel_dots: libhandy::CarouselIndicatorDots::new(),
headerbar: libhandy::HeaderBar::new(),
next_btn: gtk::Button::with_label(&gettext("_Next")),
finish_btn: gtk::Button::with_label(&gettext("_Close")),
close_btn: gtk::Button::with_label(&gettext("_Close")),
previous_btn: gtk::Button::with_label(&gettext("_Previous")),
pages: RefCell::new(Vec::new()),
......@@ -71,27 +73,22 @@ impl PaginatorWidget {
let forelast_page = n_pages - 2.0;
let last_page = n_pages - 1.0;
let (opacity_close, opacity_previous, opacity_next) =
if (0.0 <= position) && (position < 1.0) {
(0.0, position, position)
} else if (1.0 <= position) && (position <= forelast_page) {
(0.0, 1.0, 1.0)
} else if (forelast_page < position) && (position <= last_page) {
(position - forelast_page, 1.0, 1.0)
} else {
panic!("Position of the carousel is outside the allowed range");
};
let (opacity_finish, opacity_previous) = if (0.0 <= position) && (position < 1.0) {
(0.0, position)
} else if (0.0 <= position) && (position <= forelast_page) {
(0.0, 1.0)
} else if (forelast_page < position) && (position <= last_page) {
(position - forelast_page, 1.0)
} else {
panic!("Position of the carousel is outside the allowed range");
};
self.close_btn.set_opacity(opacity_close);
self.close_btn.set_visible(opacity_close > 0_f64);
self.finish_btn.set_opacity(opacity_finish);
self.finish_btn.set_visible(opacity_finish > 0_f64);
self.previous_btn.set_opacity(opacity_previous);
self.previous_btn.set_visible(opacity_previous > 0_f64);
self.next_btn.set_opacity(opacity_next);
self.next_btn.set_visible(opacity_next > 0_f64);
self.headerbar.set_opacity(opacity_next);
self.current_page.replace(page_nr);
}
......@@ -107,36 +104,46 @@ impl PaginatorWidget {
p.update_position();
}));
let btn_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Horizontal);
btn_size_group.add_widget(&self.previous_btn);
btn_size_group.add_widget(&self.next_btn);
btn_size_group.add_widget(&self.close_btn);
self.next_btn
.get_style_context()
.add_class("suggested-action");
self.next_btn.set_use_underline(true);
self.next_btn.set_action_name(Some("app.next-page"));
self.next_btn.show();
self.close_btn
.get_style_context()
.add_class("suggested-action");
self.close_btn.set_use_underline(true);
self.close_btn.set_action_name(Some("app.quit"));
self.close_btn.show();
self.finish_btn
.get_style_context()
.add_class("suggested-action");
self.finish_btn.set_use_underline(true);
self.finish_btn.set_action_name(Some("app.quit"));
self.previous_btn.set_use_underline(true);
self.previous_btn.set_action_name(Some("app.previous-page"));
let previous_overlay = gtk::Overlay::new();
previous_overlay.add(&self.close_btn);
previous_overlay.add_overlay(&self.previous_btn);
previous_overlay.show();
let next_overlay = gtk::Overlay::new();
next_overlay.add(&self.next_btn);
next_overlay.add_overlay(&self.close_btn);
next_overlay.add_overlay(&self.finish_btn);
next_overlay.show();
let btn_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Horizontal);
btn_size_group.add_widget(&self.previous_btn);
btn_size_group.add_widget(&self.close_btn);
btn_size_group.add_widget(&self.next_btn);
btn_size_group.add_widget(&self.finish_btn);
self.headerbar.set_custom_title(Some(&self.carousel_dots));
self.headerbar.pack_start(&self.previous_btn);
self.headerbar.pack_start(&previous_overlay);
self.headerbar.pack_end(&next_overlay);
self.headerbar.set_show_close_button(false);
self.headerbar.set_opacity(0_f64);
self.headerbar.show();
self.widget.add(&self.headerbar);
......
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