Add language selection
This commit is contained in:
parent
89079b6de4
commit
769d077c9e
@ -53,40 +53,6 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
.margin_end(15)
|
.margin_end(15)
|
||||||
.sensitive(false)
|
.sensitive(false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// create the bottom box for next and back buttons
|
|
||||||
let bottom_box = gtk::Box::builder()
|
|
||||||
.orientation(Orientation::Horizontal)
|
|
||||||
.visible(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Next and back button
|
|
||||||
let bottom_back_button = gtk::Button::builder()
|
|
||||||
.label("Back")
|
|
||||||
.margin_top(15)
|
|
||||||
.margin_bottom(15)
|
|
||||||
.margin_start(15)
|
|
||||||
.margin_end(15)
|
|
||||||
.halign(gtk::Align::Start)
|
|
||||||
.hexpand(true)
|
|
||||||
.build();
|
|
||||||
let bottom_next_button = gtk::Button::builder()
|
|
||||||
.label("Next")
|
|
||||||
.margin_top(15)
|
|
||||||
.margin_bottom(15)
|
|
||||||
.margin_start(15)
|
|
||||||
.margin_end(15)
|
|
||||||
.halign(gtk::Align::End)
|
|
||||||
.hexpand(true)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Start Applying css classes
|
|
||||||
bottom_next_button.add_css_class("suggested-action");
|
|
||||||
|
|
||||||
// / bottom_box appends
|
|
||||||
//// Add the next and back buttons
|
|
||||||
bottom_box.append(&bottom_back_button);
|
|
||||||
bottom_box.append(&bottom_next_button);
|
|
||||||
|
|
||||||
// / _main_box appends
|
// / _main_box appends
|
||||||
//// Add the a title bar to the _main_box
|
//// Add the a title bar to the _main_box
|
||||||
@ -95,19 +61,8 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
_main_box.append(&content_stack_switcher);
|
_main_box.append(&content_stack_switcher);
|
||||||
//// Add the stack pager containing all the steps to _main_box
|
//// Add the stack pager containing all the steps to _main_box
|
||||||
_main_box.append(&content_stack);
|
_main_box.append(&content_stack);
|
||||||
//// Add the the next and back buttons box to _main_box
|
//// Add the the next and back buttons box to _main_box (moved)
|
||||||
_main_box.append(&bottom_box);
|
///_main_box.append(&bottom_box);
|
||||||
|
|
||||||
// Add welcome_page.rs as a page for content_stack
|
|
||||||
welcome_page(&content_stack);
|
|
||||||
// if content_stack visible child becomes NOT content_stack, show the buttom box
|
|
||||||
content_stack.connect_visible_child_notify(clone!(@weak bottom_box => move |content_stack| {
|
|
||||||
let state = content_stack.visible_child_name().as_deref() != Some("welcome_page");
|
|
||||||
bottom_box.set_visible(state);
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Add language_page.rs as a page for content_stack
|
|
||||||
language_page(&content_stack);
|
|
||||||
|
|
||||||
// create the main Application window
|
// create the main Application window
|
||||||
let window = adw::ApplicationWindow::builder()
|
let window = adw::ApplicationWindow::builder()
|
||||||
@ -132,6 +87,19 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
// build the window
|
// build the window
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
// Add welcome_page.rs as a page for content_stack
|
||||||
|
welcome_page(&window, &content_stack);
|
||||||
|
|
||||||
|
// bottom_box moved per page
|
||||||
|
// if content_stack visible child becomes NOT content_stack, show the buttom box
|
||||||
|
//content_stack.connect_visible_child_notify(clone!(@weak bottom_box => move |content_stack| {
|
||||||
|
// let state = content_stack.visible_child_name().as_deref() != Some("welcome_page");
|
||||||
|
// bottom_box.set_visible(state);
|
||||||
|
// }));
|
||||||
|
|
||||||
|
// Add language_page.rs as a page for content_stack
|
||||||
|
language_page(&content_stack);
|
||||||
|
|
||||||
// glib maximization
|
// glib maximization
|
||||||
if glib_settings.boolean("is-maximized") == true {
|
if glib_settings.boolean("is-maximized") == true {
|
||||||
window.maximize()
|
window.maximize()
|
||||||
@ -145,9 +113,10 @@ pub fn build_ui(app: &adw::Application) {
|
|||||||
// Connect the hiding of window to the save_window_size function and window destruction
|
// Connect the hiding of window to the save_window_size function and window destruction
|
||||||
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
|
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
|
||||||
window.connect_hide(clone!(@weak window => move |_| window.destroy()));
|
window.connect_hide(clone!(@weak window => move |_| window.destroy()));
|
||||||
let content_stack_clone = content_stack.clone();
|
// bottom_box moved per page
|
||||||
let content_stack_clone2 = content_stack.clone();
|
//let content_stack_clone = content_stack.clone();
|
||||||
bottom_next_button.connect_clicked(move |_| content_stack_clone.set_visible_child(&content_stack_clone.visible_child().expect("null").next_sibling().unwrap()));
|
//let content_stack_clone2 = content_stack.clone();
|
||||||
bottom_back_button.connect_clicked(move |_| content_stack_clone2.set_visible_child(&content_stack_clone2.visible_child().expect("null").prev_sibling().unwrap()));
|
//bottom_next_button.connect_clicked(move |_| content_stack_clone.set_visible_child(&content_stack_clone.visible_child().expect("null").next_sibling().unwrap()));
|
||||||
|
//bottom_back_button.connect_clicked(move |_| content_stack_clone2.set_visible_child(&content_stack_clone2.visible_child().expect("null").prev_sibling().unwrap()));
|
||||||
window.show();
|
window.show();
|
||||||
}
|
}
|
@ -11,6 +11,43 @@ use gdk::Display;
|
|||||||
use gtk::subclass::layout_child;
|
use gtk::subclass::layout_child;
|
||||||
|
|
||||||
pub fn language_page(content_stack: >k::Stack) {
|
pub fn language_page(content_stack: >k::Stack) {
|
||||||
|
|
||||||
|
// create the bottom box for next and back buttons
|
||||||
|
let bottom_box = gtk::Box::builder()
|
||||||
|
.orientation(Orientation::Horizontal)
|
||||||
|
.valign(gtk::Align::End)
|
||||||
|
.vexpand(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Next and back button
|
||||||
|
let bottom_back_button = gtk::Button::builder()
|
||||||
|
.label("Back")
|
||||||
|
.margin_top(15)
|
||||||
|
.margin_bottom(15)
|
||||||
|
.margin_start(15)
|
||||||
|
.margin_end(15)
|
||||||
|
.halign(gtk::Align::Start)
|
||||||
|
.hexpand(true)
|
||||||
|
.build();
|
||||||
|
let bottom_next_button = gtk::Button::builder()
|
||||||
|
.label("Next")
|
||||||
|
.margin_top(15)
|
||||||
|
.margin_bottom(15)
|
||||||
|
.margin_start(15)
|
||||||
|
.margin_end(15)
|
||||||
|
.halign(gtk::Align::End)
|
||||||
|
.hexpand(true)
|
||||||
|
.sensitive(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Start Applying css classes
|
||||||
|
bottom_next_button.add_css_class("suggested-action");
|
||||||
|
|
||||||
|
// / bottom_box appends
|
||||||
|
//// Add the next and back buttons
|
||||||
|
bottom_box.append(&bottom_back_button);
|
||||||
|
bottom_box.append(&bottom_next_button);
|
||||||
|
|
||||||
// the header box for the language page
|
// the header box for the language page
|
||||||
let language_main_box = gtk::Box::builder()
|
let language_main_box = gtk::Box::builder()
|
||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Vertical)
|
||||||
@ -87,17 +124,37 @@ pub fn language_page(content_stack: >k::Stack) {
|
|||||||
.build();
|
.build();
|
||||||
language_selection_expander_row.add_row(&null_checkbutton);
|
language_selection_expander_row.add_row(&null_checkbutton);
|
||||||
|
|
||||||
|
let null_checkbutton_clone = null_checkbutton.clone();
|
||||||
|
let language_selection_expander_row_clone2 = language_selection_expander_row.clone();
|
||||||
|
let bottom_next_button_clone = bottom_next_button.clone();
|
||||||
|
|
||||||
|
|
||||||
|
null_checkbutton.connect_toggled(move |_| {
|
||||||
|
if null_checkbutton_clone.is_active() == true {
|
||||||
|
language_selection_expander_row_clone2.set_title("No locale selected");
|
||||||
|
bottom_next_button_clone.set_sensitive(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
for locale in locales {
|
for locale in locales {
|
||||||
let locale_label = gtk::CheckButton::builder()
|
let locale_checkbutton = gtk::CheckButton::builder()
|
||||||
.label(locale)
|
.label(locale)
|
||||||
.build();
|
.build();
|
||||||
locale_label.set_group(Some(&null_checkbutton));
|
locale_checkbutton.set_group(Some(&null_checkbutton));
|
||||||
language_selection_expander_row.add_row(&locale_label);
|
language_selection_expander_row.add_row(&locale_checkbutton);
|
||||||
|
let language_selection_expander_row_clone = language_selection_expander_row.clone();
|
||||||
|
let locale_checkbutton_clone = locale_checkbutton.clone();
|
||||||
|
let bottom_next_button_clone2 = bottom_next_button.clone();
|
||||||
|
locale_checkbutton.connect_toggled(move |_| {
|
||||||
|
if locale_checkbutton_clone.is_active() == true {
|
||||||
|
language_selection_expander_row_clone.set_title(locale);
|
||||||
|
bottom_next_button_clone2.set_sensitive(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// / language_selection_box appends
|
// / language_selection_box appends
|
||||||
//// add text and and entry to language page selections
|
//// add text and and entry to language page selections
|
||||||
language_selection_box.append(&language_selection_text);
|
language_selection_box.append(&language_selection_text);
|
||||||
@ -113,8 +170,20 @@ pub fn language_page(content_stack: >k::Stack) {
|
|||||||
language_main_box.append(&language_header_box);
|
language_main_box.append(&language_header_box);
|
||||||
//// Add the language selection/page content box to language main box
|
//// Add the language selection/page content box to language main box
|
||||||
language_main_box.append(&language_selection_box);
|
language_main_box.append(&language_selection_box);
|
||||||
|
|
||||||
|
language_main_box.append(&bottom_box);
|
||||||
|
|
||||||
// / Content stack appends
|
// / Content stack appends
|
||||||
//// Add the language_main_box as page: language_page, Give it nice title
|
//// Add the language_main_box as page: language_page, Give it nice title
|
||||||
content_stack.add_titled(&language_main_box, Some("language_page"), "Language");
|
content_stack.add_titled(&language_main_box, Some("language_page"), "Language");
|
||||||
}
|
|
||||||
|
let content_stack_clone = content_stack.clone();
|
||||||
|
let content_stack_clone2 = content_stack.clone();
|
||||||
|
bottom_next_button.connect_clicked(move |_| {
|
||||||
|
content_stack_clone.set_visible_child_name("keyboard_page")
|
||||||
|
});
|
||||||
|
bottom_back_button.connect_clicked(move |_| {
|
||||||
|
content_stack_clone2.set_visible_child_name("welcome_page")
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@ use glib::*;
|
|||||||
use gdk::Display;
|
use gdk::Display;
|
||||||
use gtk::subclass::layout_child;
|
use gtk::subclass::layout_child;
|
||||||
|
|
||||||
pub fn welcome_page(content_stack: >k::Stack) {
|
pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) {
|
||||||
// the header box for the welcome page
|
// the header box for the welcome page
|
||||||
let welcome_main_box = gtk::Box::builder()
|
let welcome_main_box = gtk::Box::builder()
|
||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Vertical)
|
||||||
@ -164,6 +164,8 @@ pub fn welcome_page(content_stack: >k::Stack) {
|
|||||||
//// Add the welcome_main_box as page: welcome_page, Give it nice title
|
//// Add the welcome_main_box as page: welcome_page, Give it nice title
|
||||||
content_stack.add_titled(&welcome_main_box, Some("welcome_page"), "Welcome");
|
content_stack.add_titled(&welcome_main_box, Some("welcome_page"), "Welcome");
|
||||||
let content_stack_clone = content_stack.clone();
|
let content_stack_clone = content_stack.clone();
|
||||||
|
let window_clone = window.clone();
|
||||||
install_media_button.connect_clicked(move |_| content_stack_clone.set_visible_child_name("language_page"));
|
install_media_button.connect_clicked(move |_| content_stack_clone.set_visible_child_name("language_page"));
|
||||||
|
live_media_button.connect_clicked(move |_| window_clone.hide());
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user