Commit dbb6cbe0 authored by Julian Hofer's avatar Julian Hofer

Use the builder-pattern for various widgets

parent a37f7b95
...@@ -19,34 +19,41 @@ impl ImagePageWidget { ...@@ -19,34 +19,41 @@ impl ImagePageWidget {
self.widget.set_halign(gtk::Align::Fill); self.widget.set_halign(gtk::Align::Fill);
self.widget.set_valign(gtk::Align::Fill); self.widget.set_valign(gtk::Align::Fill);
let container = gtk::Box::new(gtk::Orientation::Vertical, 12); let container = gtk::BoxBuilder::new()
container.set_halign(gtk::Align::Center); .orientation(gtk::Orientation::Vertical)
container.set_valign(gtk::Align::Center); .spacing(12)
container.set_vexpand(true); .halign(gtk::Align::Center)
container.set_margin_bottom(48); .valign(gtk::Align::Center)
container.set_margin_top(12); .vexpand(true)
container.set_margin_start(12); .margin_bottom(48)
container.set_margin_end(12); .margin_top(12)
.margin_start(12)
.margin_end(12)
.build();
let image = gtk::Image::from_resource(&resource_uri); let image = gtk::Image::from_resource(&resource_uri);
image.set_valign(gtk::Align::Start); image.set_valign(gtk::Align::Start);
image.show(); image.show();
container.add(&image); container.add(&image);
let head_label = gtk::Label::new(Some(&head)); let head_label = gtk::LabelBuilder::new()
head_label.set_justify(gtk::Justification::Center); .label(&head)
head_label.set_valign(gtk::Align::Center); .justify(gtk::Justification::Center)
head_label.set_margin_top(36); .valign(gtk::Align::Center)
.margin_top(36)
.build();
head_label.get_style_context().add_class("page-title"); head_label.get_style_context().add_class("page-title");
head_label.show(); head_label.show();
container.add(&head_label); container.add(&head_label);
let body_label = gtk::Label::new(Some(&body)); let body_label = gtk::LabelBuilder::new()
body_label.set_lines(2); .label(&body)
body_label.set_property_wrap(true); .lines(2)
body_label.set_justify(gtk::Justification::Center); .wrap(true)
body_label.set_valign(gtk::Align::Center); .justify(gtk::Justification::Center)
body_label.set_margin_top(12); .valign(gtk::Align::Center)
.margin_top(12)
.build();
body_label.get_style_context().add_class("page-body"); body_label.get_style_context().add_class("page-body");
body_label.show(); body_label.show();
container.add(&body_label); container.add(&body_label);
......
...@@ -60,13 +60,15 @@ impl WelcomePageWidget { ...@@ -60,13 +60,15 @@ impl WelcomePageWidget {
} }
fn init(&self) { fn init(&self) {
let container = gtk::Box::new(gtk::Orientation::Vertical, 0); let container = gtk::BoxBuilder::new()
.orientation(gtk::Orientation::Vertical)
container.set_property_expand(true); .spacing(0)
container.set_valign(gtk::Align::Center); .expand(true)
container.set_halign(gtk::Align::Center); .valign(gtk::Align::Center)
container.set_margin_top(24); .halign(gtk::Align::Center)
container.set_margin_bottom(24); .margin_top(24)
.margin_bottom(24)
.build();
#[cfg(not(feature = "video"))] #[cfg(not(feature = "video"))]
let header = { let header = {
...@@ -154,23 +156,30 @@ impl WelcomePageWidget { ...@@ -154,23 +156,30 @@ impl WelcomePageWidget {
text.show(); text.show();
container.add(&text); container.add(&text);
let actions_container = gtk::Box::new(gtk::Orientation::Horizontal, 12); let actions_container = gtk::BoxBuilder::new()
actions_container.set_halign(gtk::Align::Center); .orientation(gtk::Orientation::Horizontal)
actions_container.set_margin_top(36); .spacing(12)
.halign(gtk::Align::Center)
let skip_tour_btn = gtk::Button::with_label(&gettext("_No Thanks")); .margin_top(36)
skip_tour_btn.set_property_height_request(40); .build();
skip_tour_btn.set_property_width_request(180);
skip_tour_btn.set_use_underline(true); let skip_tour_btn = gtk::ButtonBuilder::new()
skip_tour_btn.set_action_name(Some("app.skip-tour")); .label(&gettext("_No Thanks"))
.height_request(40)
.width_request(180)
.use_underline(true)
.action_name("app.skip-tour")
.build();
skip_tour_btn.show(); skip_tour_btn.show();
actions_container.add(&skip_tour_btn); actions_container.add(&skip_tour_btn);
let start_tour_btn = gtk::Button::with_label(&gettext("_Start Tour")); let start_tour_btn = gtk::ButtonBuilder::new()
start_tour_btn.set_property_height_request(40); .label(&gettext("_Start Tour"))
start_tour_btn.set_property_width_request(180); .height_request(40)
start_tour_btn.set_use_underline(true); .width_request(180)
start_tour_btn.set_action_name(Some("app.start-tour")); .use_underline(true)
.action_name("app.start-tour")
.build();
start_tour_btn.get_style_context().add_class("suggested-action"); start_tour_btn.get_style_context().add_class("suggested-action");
start_tour_btn.show(); start_tour_btn.show();
actions_container.add(&start_tour_btn); actions_container.add(&start_tour_btn);
......
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