sort keymap and lang
This commit is contained in:
parent
7beeb231ad
commit
785f820c50
@ -5,6 +5,11 @@ use gnome_desktop::XkbInfoExt;
|
||||
use gtk::{gio, glib, prelude::*};
|
||||
use std::{cell::RefCell, fs, path::Path, process::Command, rc::Rc};
|
||||
|
||||
struct PikaKeymap {
|
||||
name: String,
|
||||
pretty_name: String
|
||||
}
|
||||
|
||||
pub fn keyboard_page(
|
||||
main_carousel: &adw::Carousel,
|
||||
keymap_base_data_refcell: &Rc<RefCell<String>>,
|
||||
@ -69,9 +74,18 @@ pub fn keyboard_page(
|
||||
|
||||
let keymap_list = gnome_desktop::XkbInfo::all_layouts(&xkbinfo);
|
||||
|
||||
let mut sorted_keymap_vec = Vec::new();
|
||||
for keymap in keymap_list.iter() {
|
||||
let keymap = keymap.to_string();
|
||||
let keymap_name = xkbinfo.layout_info(&keymap).unwrap().0.unwrap().to_string();
|
||||
sorted_keymap_vec.push(PikaKeymap{
|
||||
name: keymap.to_string(),
|
||||
pretty_name: xkbinfo.layout_info(&keymap).unwrap().0.unwrap().to_string()
|
||||
})
|
||||
}
|
||||
sorted_keymap_vec.sort_by_key(|k| k.pretty_name.clone());
|
||||
|
||||
for pika_keymap in sorted_keymap_vec {
|
||||
let keymap = pika_keymap.name;
|
||||
let keymap_name = pika_keymap.pretty_name;
|
||||
let keymap_split: Vec<String> = keymap.split("+").map(|s| s.into()).collect();
|
||||
let keymap_base = keymap_split.get(0).unwrap().clone();
|
||||
let mut keymap_variant = String::new();
|
||||
|
@ -4,6 +4,11 @@ use glib::{clone, closure_local};
|
||||
use gtk::{gio, glib, prelude::*};
|
||||
use std::{cell::RefCell, env, fs, path::Path, process::Command, rc::Rc};
|
||||
|
||||
struct PikaLocale {
|
||||
name: String,
|
||||
pretty_name: String
|
||||
}
|
||||
|
||||
pub fn language_page(
|
||||
main_carousel: &adw::Carousel,
|
||||
lang_data_refcell: &Rc<RefCell<String>>,
|
||||
@ -82,12 +87,21 @@ pub fn language_page(
|
||||
"cy_GB", "wo_SN", "fy_NL", "xh_ZA", "yi_US", "yo_NG", "zu_ZA", "zu_ZA", "pt_BR", "pt_PT",
|
||||
];
|
||||
|
||||
let mut sorted_locale_vec = Vec::new();
|
||||
for locale in locale_list.iter() {
|
||||
let locale = locale.to_string();
|
||||
let locale_name = gnome_desktop::language_from_locale(&locale, None)
|
||||
sorted_locale_vec.push(PikaLocale{
|
||||
name: locale.to_string(),
|
||||
pretty_name: gnome_desktop::language_from_locale(&locale, None)
|
||||
.unwrap_or(locale.clone().into())
|
||||
.to_string();
|
||||
let locale_clone = locale.clone();
|
||||
.to_string()
|
||||
})
|
||||
}
|
||||
sorted_locale_vec.sort_by_key(|k| k.pretty_name.clone());
|
||||
|
||||
for pika_locale in sorted_locale_vec {
|
||||
let locale = pika_locale.name;
|
||||
let locale_clone0 = locale.clone();
|
||||
let locale_name = pika_locale.pretty_name;
|
||||
let locale_checkbutton = gtk::CheckButton::builder()
|
||||
.valign(gtk::Align::Center)
|
||||
.can_focus(false)
|
||||
@ -114,7 +128,7 @@ pub fn language_page(
|
||||
}
|
||||
}
|
||||
));
|
||||
if ¤t_locale == &locale_clone
|
||||
if ¤t_locale == &locale_clone0
|
||||
&& current_locale != "C.UTF-8"
|
||||
&& current_locale != "C"
|
||||
&& current_locale != "C.utf8"
|
||||
|
Loading…
Reference in New Issue
Block a user