[gnome-tour/bilelmoussaoui/headerbar: 2/2] welcome page: always how a headerbar
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tour/bilelmoussaoui/headerbar: 2/2] welcome page: always how a headerbar
- Date: Fri, 5 Feb 2021 22:38:52 +0000 (UTC)
commit 6926f74484aafccb7ae77eff7e346fd3858c8d04
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Fri Feb 5 23:38:01 2021 +0100
welcome page: always how a headerbar
fixes #30
src/widgets/pages/welcome.rs | 35 -------------------------
src/widgets/paginator.rs | 61 ++++++++++++++++++++++++--------------------
2 files changed, 34 insertions(+), 62 deletions(-)
---
diff --git a/src/widgets/pages/welcome.rs b/src/widgets/pages/welcome.rs
index fe22505..0c841d4 100644
--- a/src/widgets/pages/welcome.rs
+++ b/src/widgets/pages/welcome.rs
@@ -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();
diff --git a/src/widgets/paginator.rs b/src/widgets/paginator.rs
index b0de46b..12226a5 100644
--- a/src/widgets/paginator.rs
+++ b/src/widgets/paginator.rs
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]