RR: Add search bars
This commit is contained in:
parent
a722ef7c04
commit
37c0b5a901
@ -127,7 +127,7 @@ pub fn keyboard_page(content_stack: >k::Stack) {
|
||||
.build();
|
||||
|
||||
let keyboard_selection_expander_row_viewport =
|
||||
gtk::ScrolledWindow::builder().height_request(450).build();
|
||||
gtk::ScrolledWindow::builder().height_request(355).build();
|
||||
|
||||
let keyboard_selection_expander_row_viewport_box = gtk::ListBox::builder()
|
||||
.build();
|
||||
@ -148,6 +148,16 @@ pub fn keyboard_page(content_stack: >k::Stack) {
|
||||
|
||||
keyboard_selection_expander_row.add_row(&keyboard_selection_expander_row_viewport);
|
||||
|
||||
let keyboard_search_bar = gtk::SearchEntry::builder()
|
||||
.halign(gtk::Align::Center)
|
||||
.hexpand(true)
|
||||
.margin_top(15)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.search_delay(500)
|
||||
.build();
|
||||
|
||||
let current_keyboard_cli = Command::new("localectl")
|
||||
.arg("status")
|
||||
.stdin(Stdio::piped())
|
||||
@ -220,6 +230,7 @@ pub fn keyboard_page(content_stack: >k::Stack) {
|
||||
// / keyboard_selection_box appends
|
||||
//// add text and and entry to keyboard page selections
|
||||
keyboard_selection_box.append(&keyboard_selection_text);
|
||||
keyboard_selection_box.append(&keyboard_search_bar);
|
||||
keyboard_selection_box.append(&keyboard_selection_expander_row_viewport_listbox);
|
||||
|
||||
// / keyboard_header_box appends
|
||||
@ -259,6 +270,28 @@ pub fn keyboard_page(content_stack: >k::Stack) {
|
||||
|
||||
let keyboard_data_buffer_clone = keyboard_data_buffer.clone();
|
||||
|
||||
keyboard_search_bar.connect_search_changed(clone!(@weak keyboard_search_bar, @weak keyboard_selection_expander_row_viewport_box => move |_| {
|
||||
let mut counter = keyboard_selection_expander_row_viewport_box.first_child();
|
||||
while let Some(row) = counter {
|
||||
if row.widget_name() == "AdwActionRow" {
|
||||
if !keyboard_search_bar.text().is_empty() {
|
||||
if row.property::<String>("subtitle").to_lowercase().contains(&keyboard_search_bar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&keyboard_search_bar.text().to_string().to_lowercase()) {
|
||||
keyboard_selection_expander_row.set_expanded(true);
|
||||
//row.grab_focus();
|
||||
//row.add_css_class("highlight-widget");
|
||||
row.set_property("visible", true);
|
||||
keyboard_search_bar.grab_focus();
|
||||
} else {
|
||||
row.set_property("visible", false);
|
||||
}
|
||||
} else {
|
||||
row.set_property("visible", true);
|
||||
}
|
||||
}
|
||||
counter = row.next_sibling();
|
||||
}
|
||||
}));
|
||||
|
||||
bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| {
|
||||
if Path::new("/tmp/pika-installer-gtk4-keyboard.txt").exists() {
|
||||
fs::remove_file("/tmp/pika-installer-gtk4-keyboard.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-keyboard.txt");
|
||||
|
@ -125,11 +125,11 @@ pub fn language_page(content_stack: >k::Stack) {
|
||||
.build();
|
||||
|
||||
let language_selection_expander_row_viewport =
|
||||
gtk::ScrolledWindow::builder().height_request(200).build();
|
||||
gtk::ScrolledWindow::builder().height_request(420).build();
|
||||
|
||||
let language_selection_expander_row_viewport_box = gtk::Box::builder()
|
||||
.orientation(Orientation::Vertical)
|
||||
let language_selection_expander_row_viewport_box = gtk::ListBox::builder()
|
||||
.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));
|
||||
@ -146,6 +146,16 @@ pub fn language_page(content_stack: >k::Stack) {
|
||||
|
||||
language_selection_expander_row.add_row(&language_selection_expander_row_viewport);
|
||||
|
||||
let language_search_bar = gtk::SearchEntry::builder()
|
||||
.halign(gtk::Align::Center)
|
||||
.hexpand(true)
|
||||
.margin_top(15)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.search_delay(500)
|
||||
.build();
|
||||
|
||||
let current_locale = match env::var_os("LANG") {
|
||||
Some(v) => v.into_string().unwrap(),
|
||||
None => panic!("$LANG is not set"),
|
||||
@ -202,7 +212,7 @@ pub fn language_page(content_stack: >k::Stack) {
|
||||
lang_data_buffer.set_text(&locale);
|
||||
}
|
||||
}));
|
||||
if current_locale.contains(&(locale_clone)) {
|
||||
if current_locale.contains(&(locale_clone)) && current_locale != "C.UTF-8" && current_locale != "C" && current_locale != "C.utf8" && current_locale != "POSIX" {
|
||||
locale_checkbutton.set_active(true);
|
||||
}
|
||||
}
|
||||
@ -210,6 +220,7 @@ pub fn language_page(content_stack: >k::Stack) {
|
||||
// / language_selection_box appends
|
||||
//// add text and and entry to language page selections
|
||||
language_selection_box.append(&language_selection_text);
|
||||
language_selection_box.append(&language_search_bar);
|
||||
language_selection_box.append(&language_selection_expander_row_viewport_listbox);
|
||||
|
||||
// / language_header_box appends
|
||||
@ -235,6 +246,28 @@ pub fn language_page(content_stack: >k::Stack) {
|
||||
|
||||
let lang_data_buffer_clone = lang_data_buffer.clone();
|
||||
|
||||
language_search_bar.connect_search_changed(clone!(@weak language_search_bar, @weak language_selection_expander_row_viewport_box => move |_| {
|
||||
let mut counter = language_selection_expander_row_viewport_box.first_child();
|
||||
while let Some(row) = counter {
|
||||
if row.widget_name() == "AdwActionRow" {
|
||||
if !language_search_bar.text().is_empty() {
|
||||
if row.property::<String>("subtitle").to_lowercase().contains(&language_search_bar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&language_search_bar.text().to_string().to_lowercase()) {
|
||||
language_selection_expander_row.set_expanded(true);
|
||||
//row.grab_focus();
|
||||
//row.add_css_class("highlight-widget");
|
||||
row.set_property("visible", true);
|
||||
language_search_bar.grab_focus();
|
||||
} else {
|
||||
row.set_property("visible", false);
|
||||
}
|
||||
} else {
|
||||
row.set_property("visible", true);
|
||||
}
|
||||
}
|
||||
counter = row.next_sibling();
|
||||
}
|
||||
}));
|
||||
|
||||
bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| {
|
||||
if Path::new("/tmp/pika-installer-gtk4-lang.txt").exists() {
|
||||
fs::remove_file("/tmp/pika-installer-gtk4-lang.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-lang.txt");
|
||||
|
@ -30,3 +30,8 @@
|
||||
background-color:green;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.highlight-widget {
|
||||
background-color: @success_bg_color;
|
||||
color: @success_fg_color;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ pub fn timezone_page(content_stack: >k::Stack) {
|
||||
.build();
|
||||
|
||||
let timezone_selection_expander_row_viewport =
|
||||
gtk::ScrolledWindow::builder().height_request(200).build();
|
||||
gtk::ScrolledWindow::builder().height_request(420).build();
|
||||
|
||||
let timezone_selection_expander_row_viewport_box = gtk::ListBox::builder()
|
||||
.build();
|
||||
@ -146,6 +146,16 @@ pub fn timezone_page(content_stack: >k::Stack) {
|
||||
|
||||
timezone_selection_expander_row.add_row(&timezone_selection_expander_row_viewport);
|
||||
|
||||
let timezone_search_bar = gtk::SearchEntry::builder()
|
||||
.halign(gtk::Align::Center)
|
||||
.hexpand(true)
|
||||
.margin_top(15)
|
||||
.margin_bottom(15)
|
||||
.margin_start(15)
|
||||
.margin_end(15)
|
||||
.search_delay(500)
|
||||
.build();
|
||||
|
||||
let current_timezone_cli = Command::new("timedatectl")
|
||||
.arg("show")
|
||||
.arg("--va")
|
||||
@ -161,47 +171,48 @@ pub fn timezone_page(content_stack: >k::Stack) {
|
||||
.unwrap()
|
||||
.trim();
|
||||
|
||||
let timezone_layout_cli = Command::new("timedatectl")
|
||||
let timezone_cli = Command::new("timedatectl")
|
||||
.arg("list-timezones")
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap_or_else(|e| panic!("failed {}", e));
|
||||
|
||||
let timezone_layout_stdout = timezone_layout_cli.stdout.expect("could not get stdout");
|
||||
let timezone_layout_reader = BufReader::new(timezone_layout_stdout);
|
||||
let timezone_stdout = timezone_cli.stdout.expect("could not get stdout");
|
||||
let timezone_reader = BufReader::new(timezone_stdout);
|
||||
|
||||
let timezone_data_buffer = gtk::TextBuffer::builder().build();
|
||||
|
||||
for timezone_layout in timezone_layout_reader.lines() {
|
||||
let timezone_layout = timezone_layout.unwrap();
|
||||
let timezone_layout_clone = timezone_layout.clone();
|
||||
let timezone_layout_checkbutton = gtk::CheckButton::builder()
|
||||
for timezone in timezone_reader.lines() {
|
||||
let timezone = timezone.unwrap();
|
||||
let timezone_clone = timezone.clone();
|
||||
let timezone_checkbutton = gtk::CheckButton::builder()
|
||||
.valign(Align::Center)
|
||||
.can_focus(false)
|
||||
.build();
|
||||
let timezone_layout_row = adw::ActionRow::builder()
|
||||
.activatable_widget(&timezone_layout_checkbutton)
|
||||
.title(timezone_layout.clone())
|
||||
let timezone_row = adw::ActionRow::builder()
|
||||
.activatable_widget(&timezone_checkbutton)
|
||||
.title(timezone.clone())
|
||||
.build();
|
||||
timezone_layout_row.add_prefix(&timezone_layout_checkbutton);
|
||||
timezone_layout_checkbutton.set_group(Some(&null_checkbutton));
|
||||
timezone_selection_expander_row_viewport_box.append(&timezone_layout_row);
|
||||
timezone_layout_checkbutton.connect_toggled(clone!(@weak timezone_layout_checkbutton, @weak timezone_selection_expander_row, @weak bottom_next_button, @weak timezone_data_buffer => move |_| {
|
||||
if timezone_layout_checkbutton.is_active() == true {
|
||||
timezone_selection_expander_row.set_title(&timezone_layout);
|
||||
timezone_row.add_prefix(&timezone_checkbutton);
|
||||
timezone_checkbutton.set_group(Some(&null_checkbutton));
|
||||
timezone_selection_expander_row_viewport_box.append(&timezone_row);
|
||||
timezone_checkbutton.connect_toggled(clone!(@weak timezone_checkbutton, @weak timezone_selection_expander_row, @weak bottom_next_button, @weak timezone_data_buffer => move |_| {
|
||||
if timezone_checkbutton.is_active() == true {
|
||||
timezone_selection_expander_row.set_title(&timezone);
|
||||
bottom_next_button.set_sensitive(true);
|
||||
timezone_data_buffer.set_text(&timezone_layout);
|
||||
timezone_data_buffer.set_text(&timezone);
|
||||
}
|
||||
}));
|
||||
if current_timezone.contains(&(timezone_layout_clone)) {
|
||||
timezone_layout_checkbutton.set_active(true);
|
||||
if current_timezone.contains(&(timezone_clone)) {
|
||||
timezone_checkbutton.set_active(true);
|
||||
}
|
||||
}
|
||||
|
||||
// / timezone_selection_box appends
|
||||
//// add text and and entry to timezone page selections
|
||||
timezone_selection_box.append(&timezone_selection_text);
|
||||
timezone_selection_box.append(&timezone_search_bar);
|
||||
timezone_selection_box.append(&timezone_selection_expander_row_viewport_listbox);
|
||||
|
||||
// / timezone_header_box appends
|
||||
@ -227,6 +238,28 @@ pub fn timezone_page(content_stack: >k::Stack) {
|
||||
|
||||
let timezone_data_buffer_clone = timezone_data_buffer.clone();
|
||||
|
||||
timezone_search_bar.connect_search_changed(clone!(@weak timezone_search_bar, @weak timezone_selection_expander_row_viewport_box => move |_| {
|
||||
let mut counter = timezone_selection_expander_row_viewport_box.first_child();
|
||||
while let Some(row) = counter {
|
||||
if row.widget_name() == "AdwActionRow" {
|
||||
if !timezone_search_bar.text().is_empty() {
|
||||
if row.property::<String>("subtitle").to_lowercase().contains(&timezone_search_bar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&timezone_search_bar.text().to_string().to_lowercase()) {
|
||||
timezone_selection_expander_row.set_expanded(true);
|
||||
//row.grab_focus();
|
||||
//row.add_css_class("highlight-widget");
|
||||
row.set_property("visible", true);
|
||||
timezone_search_bar.grab_focus();
|
||||
} else {
|
||||
row.set_property("visible", false);
|
||||
}
|
||||
} else {
|
||||
row.set_property("visible", true);
|
||||
}
|
||||
}
|
||||
counter = row.next_sibling();
|
||||
}
|
||||
}));
|
||||
|
||||
bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| {
|
||||
if Path::new("/tmp/pika-installer-gtk4-timezone.txt").exists() {
|
||||
fs::remove_file("/tmp/pika-installer-gtk4-timezone.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-timezone.txt");
|
||||
|
Loading…
Reference in New Issue
Block a user