libadw widgets

This commit is contained in:
Ward from fusion-voyager-3 2024-01-17 16:24:47 +03:00
parent 72d2da4853
commit d0f996fde4
2 changed files with 41 additions and 45 deletions

View File

@ -116,10 +116,6 @@ pub fn keyboard_page(content_stack: &gtk::Stack) {
keyboard_selection_text.add_css_class("medium_sized_text"); keyboard_selection_text.add_css_class("medium_sized_text");
let keyboard_selection_expander_row = adw::ExpanderRow::builder() let keyboard_selection_expander_row = adw::ExpanderRow::builder()
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.title("No Keyboard Layout selected") .title("No Keyboard Layout selected")
.build(); .build();
@ -135,6 +131,16 @@ pub fn keyboard_page(content_stack: &gtk::Stack) {
.orientation(Orientation::Vertical) .orientation(Orientation::Vertical)
.build(); .build();
let keyboard_selection_expander_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(SelectionMode::None)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.build();
keyboard_selection_expander_row_viewport_listbox.add_css_class("boxed-list");
keyboard_selection_expander_row_viewport_listbox.append(&keyboard_selection_expander_row);
keyboard_selection_expander_row_viewport.set_child(Some(&keyboard_selection_expander_row_viewport_box)); keyboard_selection_expander_row_viewport.set_child(Some(&keyboard_selection_expander_row_viewport_box));
keyboard_selection_expander_row.add_row(&keyboard_selection_expander_row_viewport); keyboard_selection_expander_row.add_row(&keyboard_selection_expander_row_viewport);
@ -184,7 +190,7 @@ pub fn keyboard_page(content_stack: &gtk::Stack) {
// / keyboard_selection_box appends // / keyboard_selection_box appends
//// add text and and entry to keyboard page selections //// add text and and entry to keyboard page selections
keyboard_selection_box.append(&keyboard_selection_text); keyboard_selection_box.append(&keyboard_selection_text);
keyboard_selection_box.append(&keyboard_selection_expander_row); keyboard_selection_box.append(&keyboard_selection_expander_row_viewport_listbox);
// / keyboard_header_box appends // / keyboard_header_box appends
//// Add the keyboard page header text and icon //// Add the keyboard page header text and icon

View File

@ -116,45 +116,50 @@ pub fn language_page(content_stack: &gtk::Stack) {
.build(); .build();
language_selection_text.add_css_class("medium_sized_text"); language_selection_text.add_css_class("medium_sized_text");
let language_selection_expander_row = gtk::Entry::builder() let language_selection_expander_row = adw::ExpanderRow::builder()
.margin_top(15) .title("No locale selected")
.margin_start(15)
.margin_end(15)
.build(); .build();
let null_checkbutton = gtk::CheckButton::builder() let null_checkbutton = gtk::CheckButton::builder()
.valign(Align::Center) .label("No locale selected")
.can_focus(false)
.build(); .build();
let language_selection_expander_row_viewport = gtk::ScrolledWindow::builder() let language_selection_expander_row_viewport = gtk::ScrolledWindow::builder()
.height_request(200) .height_request(200)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.build(); .build();
let language_selection_expander_row_viewport_box = gtk::ListBox::builder() let language_selection_expander_row_viewport_box = gtk::Box::builder()
.selection_mode(SelectionMode::None) .orientation(Orientation::Vertical)
.build(); .build();
language_selection_expander_row_viewport_box.add_css_class("boxed-list");
language_selection_expander_row_viewport.set_child(Some(&language_selection_expander_row_viewport_box)); language_selection_expander_row_viewport.set_child(Some(&language_selection_expander_row_viewport_box));
language_selection_expander_row.set_placeholder_text(Some("No locale selected")); let language_selection_expander_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(SelectionMode::None)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.build();
language_selection_expander_row_viewport_listbox.add_css_class("boxed-list");
language_selection_expander_row_viewport_listbox.append(&language_selection_expander_row);
let null_action_row = adw::ActionRow::builder() language_selection_expander_row.add_row(&language_selection_expander_row_viewport);
.title("No locale selected")
.activatable_widget(&null_checkbutton)
.build();
null_action_row.add_prefix(&null_checkbutton);
language_selection_expander_row_viewport_box.append(&null_action_row); language_selection_expander_row_viewport_box.append(&null_checkbutton);
let null_checkbutton_clone = null_checkbutton.clone(); let null_checkbutton_clone = null_checkbutton.clone();
let language_selection_expander_row_clone2 = language_selection_expander_row.clone(); let language_selection_expander_row_clone2 = language_selection_expander_row.clone();
let bottom_next_button_clone = bottom_next_button.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);
}
});
let mut locale_cli = Command::new("locale") let mut locale_cli = Command::new("locale")
.arg("-a") .arg("-a")
.stdin(Stdio::piped()) .stdin(Stdio::piped())
@ -174,46 +179,31 @@ pub fn language_page(content_stack: &gtk::Stack) {
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn() .spawn()
.unwrap(); .unwrap();
let locale_reader = BufReader::new(locale_cli_sort.stdout.as_mut().expect("could not get stdout")); let locale_reader = BufReader::new(locale_cli_sort.stdout.as_mut().expect("could not get stdout"));
for locale in locale_reader.lines() { for locale in locale_reader.lines() {
let locale = locale.unwrap(); let locale = locale.unwrap();
let locale_checkbutton = gtk::CheckButton::builder() let locale_checkbutton = gtk::CheckButton::builder()
.valign(Align::Center) .label(locale.clone())
.can_focus(false)
.build(); .build();
locale_checkbutton.set_group(Some(&null_checkbutton)); locale_checkbutton.set_group(Some(&null_checkbutton));
let locale_action_row = adw::ActionRow::builder() language_selection_expander_row_viewport_box.append(&locale_checkbutton);
.title(locale.clone())
.activatable_widget(&locale_checkbutton)
.build();
locale_action_row.add_prefix(&locale_checkbutton);
language_selection_expander_row_viewport_box.append(&locale_action_row);
let language_selection_expander_row_clone = language_selection_expander_row.clone(); let language_selection_expander_row_clone = language_selection_expander_row.clone();
let locale_checkbutton_clone = locale_checkbutton.clone(); let locale_checkbutton_clone = locale_checkbutton.clone();
let bottom_next_button_clone2 = bottom_next_button.clone(); let bottom_next_button_clone2 = bottom_next_button.clone();
locale_checkbutton.connect_toggled(move |_| { locale_checkbutton.connect_toggled(move |_| {
if locale_checkbutton_clone.is_active() == true { if locale_checkbutton_clone.is_active() == true {
language_selection_expander_row_clone.set_text(&locale); language_selection_expander_row_clone.set_title(&locale);
bottom_next_button_clone2.set_sensitive(true); bottom_next_button_clone2.set_sensitive(true);
} }
}); });
} }
null_checkbutton.connect_toggled(move |_| {
if null_checkbutton_clone.is_active() == true {
language_selection_expander_row_clone2.set_text(" ");
bottom_next_button_clone.set_sensitive(false);
}
});
// / 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);
language_selection_box.append(&language_selection_expander_row); language_selection_box.append(&language_selection_expander_row_viewport_listbox);
language_selection_box.append(&language_selection_expander_row_viewport);
// / language_header_box appends // / language_header_box appends
//// Add the language page header text and icon //// Add the language page header text and icon