Compare commits

...

10 Commits

Author SHA1 Message Date
3af10285b7 squeekboard-test-layout: correct dependencies and version for clap argument parsing 2019-12-13 21:37:50 +01:00
53997abc46 added librust-clap-dev to debian/control 2019-12-08 21:14:56 +01:00
34765be22e squeekboard-test-layout: add argument parsing and some more output 2019-12-08 18:29:54 +01:00
8b4c643d3e Merge branch 'german-wide-keyboard-layout' into 'master'
layout: add German wide layout

See merge request Librem5/squeekboard!271
2019-12-07 14:39:43 +00:00
358b25c431 layout: add German wide layout 2019-12-07 14:39:43 +00:00
2749fdb686 Merge branch 'click' into 'master'
Switch layout on click

Closes #157

See merge request Librem5/squeekboard!266
2019-12-05 23:49:37 +00:00
8e7909e877 Merge branch 'stable' into 'master'
keycodes: Sort to eliminate runtime indeterminism

See merge request Librem5/squeekboard!268
2019-12-05 22:20:43 +00:00
afaacd3f68 Merge branch '1.4' into 'master'
Release 1.4.0 "Nacelle"

See merge request Librem5/squeekboard!273
2019-12-02 19:53:20 +00:00
3c45e3e53c switcher: Switch layout on menu item click 2019-11-30 15:14:45 +00:00
3ac4caa3b9 keycodes: Sort to eliminate runtime indeterminism 2019-11-27 16:18:36 +00:00
8 changed files with 130 additions and 31 deletions

View File

@ -4,6 +4,7 @@ version = "0.1.0"
[dependencies]
bitflags = "1.0.*"
clap = "2.32.*"
maplit = "1.0.*"
regex = "1.1.*"
serde = { version = "1.0.*", features = ["derive"] }

View File

@ -0,0 +1,88 @@
# Maintained by: Mark Müller <markmueller86@gmail.com>
---
bounds: { x: 0, y: 1, width: 540, height: 168 }
outlines:
default:
bounds: { x: 0, y: 0, width: 48, height: 42 }
altline:
bounds: { x: 0, y: 0, width: 81, height: 42 }
wide:
bounds: { x: 0, y: 0, width: 108, height: 42 }
spaceline:
bounds: { x: 0, y: 0, width: 216, height: 42 }
special:
bounds: { x: 0, y: 0, width: 48, height: 42 }
views:
base:
- "q w e r t z u i o p ü"
- "a s d f g h j k l ö ä"
- "Shift_L y x c v b n m BackSpace"
- "show_numbers preferences space , . Return"
upper:
- "Q W E R T Z U I O P Ü"
- "A S D F G H J K L Ö Ä"
- "Shift_L Y X C V B N M BackSpace"
- "show_numbers preferences space ! ? Return"
numbers:
- "1 2 3 4 5 6 7 8 9 0"
- "@ # % & - _ + ( ) ß"
- "show_symbols , \" ' : = < > BackSpace"
- "show_letters preferences space , . Return"
symbols:
- "~ ` ´ · © ® ÷ × ¶"
- "€ £ $ ¥ ^ ° * { } |"
- "show_numbers \\ / § π τ [ ] BackSpace"
- "show_letters preferences space , . Return"
eschars:
- "ä è é ö ü Ä È É Ö Ü"
- "à â ê î ô À Â È Î Ô"
- "show_numbers « » ç Ç æ œ ß BackSpace"
- "show_letters preferences space „ “ Return"
buttons:
Shift_L:
action:
locking:
lock_view: "upper"
unlock_view: "base"
outline: "altline"
icon: "key-shift"
BackSpace:
outline: "altline"
icon: "edit-clear-symbolic"
keysym: "BackSpace"
preferences:
action: "show_prefs"
outline: "special"
icon: "keyboard-mode-symbolic"
show_numbers:
action:
set_view: "numbers"
outline: "altline"
label: "123"
show_letters:
action:
set_view: "base"
outline: "altline"
label: "abc"
show_symbols:
action:
set_view: "symbols"
outline: "altline"
label: "*/="
show_eschars:
action:
locking:
lock_view: "eschars"
unlock_view: "base"
outline: "altline"
label: "äÄ"
space:
outline: "spaceline"
text: " "
Return:
outline: "altline"
icon: "key-enter"
keysym: "Return"

1
debian/control vendored
View File

@ -12,6 +12,7 @@ Build-Depends:
libgtk-3-dev,
libcroco3-dev,
librust-bitflags-1-dev (>= 1.0),
librust-clap-2+default-dev (>= 2.32),
librust-gio+v2-44-dev,
librust-glib+v2-44-dev,
librust-glib-sys-dev,

View File

@ -1,8 +1,16 @@
#[macro_use]
extern crate clap;
extern crate rs;
use rs::tests::check_layout_file;
use std::env;
fn main() -> () {
check_layout_file(env::args().nth(1).expect("No argument given").as_str());
let matches = clap_app!(test_layout =>
(name: "squeekboard-test-layout")
(about: "Test keyboard layout for errors. Returns OK or an error message containing further information.")
(@arg INPUT: +required "Yaml keyboard layout file to test")
).get_matches();
if check_layout_file(matches.value_of("INPUT").unwrap()) == () {
println!("Test result: OK");
}
}

View File

@ -51,6 +51,15 @@ pub struct KeyState {
pub action: Action,
}
/// Sorts an iterator by converting it to a Vector and back
fn sorted<'a, I: Iterator<Item=&'a str>>(
iter: I
) -> impl Iterator<Item=&'a str> {
let mut v: Vec<&'a str> = iter.collect();
v.sort();
v.into_iter()
}
/// Generates a mapping where each key gets a keycode, starting from ~~8~~
/// HACK: starting from 9, because 8 results in keycode 0,
/// which the compositor likes to discard
@ -58,7 +67,8 @@ pub fn generate_keycodes<'a, C: IntoIterator<Item=&'a str>>(
key_names: C
) -> HashMap<String, u32> {
HashMap::from_iter(
key_names.into_iter()
// sort to remove a source of indeterminism in keycode assignment
sorted(key_names.into_iter())
.map(|name| String::from(name))
.zip(9..)
)

View File

@ -7,9 +7,9 @@ use ::locale::compare_current_locale;
use ::locale_config::system_locale;
use ::resources;
use gio::ActionExt;
use gio::ActionMapExt;
use gio::SettingsExt;
use gio::SimpleActionExt;
use glib::translate::FromGlibPtrNone;
use glib::variant::ToVariant;
use gtk::PopoverExt;
@ -195,7 +195,7 @@ pub fn show(window: EekGtkKeyboard, position: ::layout::c::Bounds) {
height: position.width.floor() as i32,
});
let action = input_names.get(0).map(|current_name| {
if let Some(current_name) = input_names.get(0) {
let current_name = current_name.to_variant();
let layout_action = gio::SimpleAction::new_stateful(
@ -204,36 +204,26 @@ pub fn show(window: EekGtkKeyboard, position: ::layout::c::Bounds) {
&current_name,
);
layout_action.connect_change_state(|_action, state| {
match state {
Some(v) => {
v.get::<String>()
.or_else(|| {
eprintln!("Variant is not string: {:?}", v);
None
})
.map(|state| set_layout("xkb".into(), state));
},
None => eprintln!("No variant selected"),
};
});
let action_group = gio::SimpleActionGroup::new();
action_group.add_action(&layout_action);
menu.insert_action_group("popup", Some(&action_group));
layout_action
});
};
menu.bind_model(Some(&model), Some("popup"));
menu.connect_closed(move |_menu| {
if let Some(layout_action) = &action {
let state = match layout_action.get_state() {
Some(v) => {
let s = v.get::<String>().or_else(|| {
eprintln!("Variant is not string: {:?}", v);
None
});
// FIXME: the `get_state` docs call for unrefing,
// but the function is nowhere to be found
// glib::Variant::unref(v);
s
},
None => {
eprintln!("No variant selected");
None
},
};
set_layout("xkb".into(), state.unwrap_or("us".into()));
}
});
menu.popup();
}

View File

@ -13,6 +13,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[
("us", include_str!("../data/keyboards/us.yaml")),
("us_wide", include_str!("../data/keyboards/us_wide.yaml")),
("de", include_str!("../data/keyboards/de.yaml")),
("de_wide", include_str!("../data/keyboards/de_wide.yaml")),
("el", include_str!("../data/keyboards/el.yaml")),
("es", include_str!("../data/keyboards/es.yaml")),
("fi", include_str!("../data/keyboards/fi.yaml")),

View File

@ -49,7 +49,7 @@ endforeach
# and the need to call it manually
foreach layout : [
'us', 'us_wide',
'de',
'de', 'de_wide',
'el',
'es',
'fi',