From a93f3c55e7adc0092a5210aa20cdc78a6e7a93fe Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 9 Dec 2019 13:38:38 +0000 Subject: [PATCH 01/15] translations: Use gnome-desktop's xkb info database for layout names --- debian/control | 1 + src/locale.rs | 75 +++++++++++++++++++++++++++++++++++++++++++++++-- src/meson.build | 1 + src/popover.rs | 63 ++++++++++++++++++++++++++++++++--------- 4 files changed, 124 insertions(+), 16 deletions(-) diff --git a/debian/control b/debian/control index 22e3cc5c..02a477af 100644 --- a/debian/control +++ b/debian/control @@ -9,6 +9,7 @@ Build-Depends: ninja-build, pkg-config, libglib2.0-dev, + libgnome-desktop-3-dev, libgtk-3-dev, libcroco3-dev, librust-bitflags-1-dev (>= 1.0), diff --git a/src/locale.rs b/src/locale.rs index 4368fc15..de5df977 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -1,24 +1,93 @@ -/*! Locale-specific functions */ +/*! Locale-specific functions. */ use std::cmp; -use std::ffi::CString; +use std::ffi::{ CStr, CString }; +use std::os::raw::c_char; +use std::ptr; +use std::str::Utf8Error; mod c { - use std::os::raw::c_char; + use super::*; + use std::os::raw::c_void; #[allow(non_camel_case_types)] pub type c_int = i32; + #[derive(Clone, Copy)] + #[repr(C)] + pub struct GnomeXkbInfo(*const c_void); + #[no_mangle] extern "C" { // from libc pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + // from gnome-desktop3 + pub fn gnome_xkb_info_new() -> GnomeXkbInfo; + pub fn gnome_xkb_info_get_layout_info ( + info: GnomeXkbInfo, + id: *const c_char, + display_name: *mut *const c_char, + short_name: *const *const c_char, + xkb_layout: *const *const c_char, + xkb_variant: *const *const c_char + ) -> c_int; + pub fn g_object_unref(o: GnomeXkbInfo); + } +} + +#[derive(Debug)] +pub enum Error { + StringConversion(Utf8Error), + NoInfo, +} + +pub struct XkbInfo(c::GnomeXkbInfo); + +impl XkbInfo { + pub fn new() -> XkbInfo { + XkbInfo(unsafe { c::gnome_xkb_info_new() }) + } + pub fn get_display_name(&self, id: &str) -> Result { + let id = cstring_safe(id); + let id_ref = id.as_ptr(); + let mut display_name: *const c_char = ptr::null(); + let found = unsafe { + c::gnome_xkb_info_get_layout_info( + self.0, + id_ref, + &mut display_name as *mut *const c_char, + ptr::null(), ptr::null(), ptr::null(), + ) + }; + if found != 0 && !display_name.is_null() { + let display_name = unsafe { CStr::from_ptr(display_name) }; + display_name.to_str() + .map(str::to_string) + .map_err(Error::StringConversion) + } else { + Err(Error::NoInfo) + } + } +} + +impl Drop for XkbInfo { + fn drop(&mut self) { + unsafe { c::g_object_unref(self.0) } } } #[derive(Clone, Debug, PartialEq)] pub struct Translation<'a>(pub &'a str); +impl<'a> Translation<'a> { + pub fn to_owned(&'a self) -> OwnedTranslation { + OwnedTranslation(self.0.to_owned()) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct OwnedTranslation(pub String); + fn cstring_safe(s: &str) -> CString { CString::new(s) .unwrap_or(CString::new("").unwrap()) diff --git a/src/meson.build b/src/meson.build index e3a90935..9763f647 100644 --- a/src/meson.build +++ b/src/meson.build @@ -39,6 +39,7 @@ cc = meson.get_compiler('c') deps = [ # dependency('glib-2.0', version: '>=2.26.0'), dependency('gio-2.0', version: '>=2.26.0'), + dependency('gnome-desktop-3.0', version: '>=3.0'), dependency('gtk+-3.0', version: '>=3.0'), dependency('libcroco-0.6'), dependency('wayland-client', version: '>=1.14'), diff --git a/src/popover.rs b/src/popover.rs index 2319fc6d..ee99c1c8 100644 --- a/src/popover.rs +++ b/src/popover.rs @@ -4,7 +4,8 @@ use gio; use gtk; use std::ffi::CString; use ::layout::c::{ Bounds, EekGtkKeyboard }; -use ::locale::{ Translation, compare_current_locale }; +use ::locale; +use ::locale::{ OwnedTranslation, Translation, compare_current_locale }; use ::locale_config::system_locale; use ::manager; use ::resources; @@ -94,7 +95,7 @@ mod variants { } } -fn make_menu_builder(inputs: Vec<(&str, Translation)>) -> gtk::Builder { +fn make_menu_builder(inputs: Vec<(&str, OwnedTranslation)>) -> gtk::Builder { let mut xml: Vec = Vec::new(); writeln!( xml, @@ -227,37 +228,73 @@ pub fn show( ) .and_then(|lang| resources::get_layout_names(lang.as_str())); + // The actual translation procedure attempts to take all xkb names + // from gnome-desktop's xkb info. + // Remaining names are translated using the internal database, + // which is only available if the locale is set. + // The result is a rather ugly and verbose translation procedure... + enum Status { + /// xkb names should get all translated here + Translated(OwnedTranslation), + /// Builtin names need builtin translations + Remaining(String), + } + + let xkb_translator = locale::XkbInfo::new(); + let translated_names = all_layouts.iter() - .map(LayoutId::get_name); - let translated_names: Vec = match translations { + .map(|id| match id { + LayoutId::System { name, kind: _ } => { + xkb_translator.get_display_name(name) + .map(|s| Status::Translated(OwnedTranslation(s))) + .unwrap_or_else(|e| { + eprintln!( + "No display name for xkb layout {}: {:?}", + name, + e, + ); + Status::Remaining(name.clone()) + }) + }, + LayoutId::Local(name) => Status::Remaining(name.clone()), + }); + + let translated_names: Vec = match translations { Some(translations) => { translated_names - .map(move |name| { - translations.get(name) - .map(|translation| translation.clone()) - .unwrap_or(Translation(name)) + .map(|status| match status { + Status::Remaining(name) => { + translations.get(name.as_str()) + .unwrap_or(&Translation(name.as_str())) + .to_owned() + }, + Status::Translated(t) => t, }) .collect() }, None => { - translated_names.map(|name| Translation(name)) + translated_names + .map(|status| match status { + Status::Remaining(name) => OwnedTranslation(name), + Status::Translated(t) => t, + }) .collect() }, }; // sorted collection of human and machine names - let mut human_names: Vec<(Translation, LayoutId)> = translated_names + let mut human_names: Vec<(OwnedTranslation, LayoutId)> = translated_names .into_iter() .zip(all_layouts.clone().into_iter()) .collect(); human_names.sort_unstable_by(|(tr_a, _), (tr_b, _)| { - compare_current_locale(tr_a.0, tr_b.0) + compare_current_locale(&tr_a.0, &tr_b.0) }); // GVariant doesn't natively support `enum`s, // so the `choices` vector will serve as a lookup table. - let choices_with_translations: Vec<(String, (Translation, LayoutId))> + let choices_with_translations: Vec<(String, (OwnedTranslation, LayoutId))> = human_names.into_iter() .enumerate() .map(|(i, human_entry)| {( @@ -268,7 +305,7 @@ pub fn show( let builder = make_menu_builder( choices_with_translations.iter() - .map(|(id, (translation, _))| (id.as_str(), translation.clone())) + .map(|(id, (translation, _))| (id.as_str(), (*translation).clone())) .collect() ); From 0bfd846139edd895ccdc3e5daa07acf5cd4a2ce9 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 11 Dec 2019 15:20:29 +0000 Subject: [PATCH 02/15] translations: Make the code cleaner --- src/locale.rs | 8 ++- src/logging.rs | 14 ++++- src/popover.rs | 140 +++++++++++++++++++++++++++---------------------- src/style.rs | 9 ++-- src/util.rs | 5 ++ 5 files changed, 108 insertions(+), 68 deletions(-) diff --git a/src/locale.rs b/src/locale.rs index de5df977..6b87f68c 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -1,4 +1,10 @@ -/*! Locale-specific functions. */ +/*! Locale-specific functions. + * + * This file is intended as a library: + * it must pass errors upwards + * and panicking is allowed only when + * this code encounters an internal inconsistency. + */ use std::cmp; use std::ffi::{ CStr, CString }; diff --git a/src/logging.rs b/src/logging.rs index 9848783e..7beb9ff1 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -70,12 +70,12 @@ pub enum Level { /// Approach 2. pub trait Warn { type Value; - fn ok_warn(self, msg: &str) -> Option; + fn or_warn(self, msg: &str) -> Option; } impl Warn for Result { type Value = T; - fn ok_warn(self, msg: &str) -> Option { + fn or_warn(self, msg: &str) -> Option { self.map_err(|e| { eprintln!("{}: {}", msg, e); e @@ -83,6 +83,16 @@ impl Warn for Result { } } +impl Warn for Option { + type Value = T; + fn or_warn(self, msg: &str) -> Option { + self.or_else(|| { + eprintln!("{}", msg); + None + }) + } +} + /// A mutable handler for text warnings. /// Approach 3. pub trait WarningHandler { diff --git a/src/popover.rs b/src/popover.rs index ee99c1c8..c0b53086 100644 --- a/src/popover.rs +++ b/src/popover.rs @@ -18,6 +18,7 @@ use glib::variant::ToVariant; use gtk::PopoverExt; use gtk::WidgetExt; use std::io::Write; +use ::logging::Warn; mod variants { use glib; @@ -195,6 +196,82 @@ fn get_current_layout( } } +/// Translates all provided layout names according to current locale, +/// for the purpose of display (i.e. errors will be caught and reported) +fn translate_layout_names(layouts: &Vec) -> Vec { + // This procedure is rather ugly... + // Xkb lookup *must not* be applied to non-system layouts, + // so both translators can't be merged into one lookup table, + // therefore must be done in two steps. + // `XkbInfo` being temporary also means + // that its return values must be copied, + // forcing the use of `OwnedTranslation`. + enum Status { + /// xkb names should get all translated here + Translated(OwnedTranslation), + /// Builtin names need builtin translations + Remaining(String), + } + + // Attempt to take all xkb names from gnome-desktop's xkb info. + let xkb_translator = locale::XkbInfo::new(); + + let translated_names = layouts.iter() + .map(|id| match id { + LayoutId::System { name, kind: _ } => { + xkb_translator.get_display_name(name) + .map(|s| Status::Translated(OwnedTranslation(s))) + .unwrap_or_else(|e| { + eprintln!( + "No display name for xkb layout {}: {:?}", + name, + e, + ); + Status::Remaining(name.clone()) + }) + }, + LayoutId::Local(name) => Status::Remaining(name.clone()), + }); + + // Non-xkb layouts and weird xkb layouts + // still need to be looked up in the internal database. + let builtin_translations = system_locale() + .map(|locale| + locale.tags_for("messages") + .next().unwrap() // guaranteed to exist + .as_ref() + .to_owned() + ) + .or_warn("No locale detected") + .and_then(|lang| { + resources::get_layout_names(lang.as_str()) + .or_warn(&format!("No translations for locale {}", lang)) + }); + + match builtin_translations { + Some(translations) => { + translated_names + .map(|status| match status { + Status::Remaining(name) => { + translations.get(name.as_str()) + .unwrap_or(&Translation(name.as_str())) + .to_owned() + }, + Status::Translated(t) => t, + }) + .collect() + }, + None => { + translated_names + .map(|status| match status { + Status::Remaining(name) => OwnedTranslation(name), + Status::Translated(t) => t, + }) + .collect() + }, + } +} + pub fn show( window: EekGtkKeyboard, position: Bounds, @@ -219,69 +296,8 @@ pub fn show( .chain(overlay_layouts) .collect(); - let translations = system_locale() - .map(|locale| - locale.tags_for("messages") - .next().unwrap() // guaranteed to exist - .as_ref() - .to_owned() - ) - .and_then(|lang| resources::get_layout_names(lang.as_str())); - - // The actual translation procedure attempts to take all xkb names - // from gnome-desktop's xkb info. - // Remaining names are translated using the internal database, - // which is only available if the locale is set. - // The result is a rather ugly and verbose translation procedure... - enum Status { - /// xkb names should get all translated here - Translated(OwnedTranslation), - /// Builtin names need builtin translations - Remaining(String), - } + let translated_names = translate_layout_names(&all_layouts); - let xkb_translator = locale::XkbInfo::new(); - - let translated_names = all_layouts.iter() - .map(|id| match id { - LayoutId::System { name, kind: _ } => { - xkb_translator.get_display_name(name) - .map(|s| Status::Translated(OwnedTranslation(s))) - .unwrap_or_else(|e| { - eprintln!( - "No display name for xkb layout {}: {:?}", - name, - e, - ); - Status::Remaining(name.clone()) - }) - }, - LayoutId::Local(name) => Status::Remaining(name.clone()), - }); - - let translated_names: Vec = match translations { - Some(translations) => { - translated_names - .map(|status| match status { - Status::Remaining(name) => { - translations.get(name.as_str()) - .unwrap_or(&Translation(name.as_str())) - .to_owned() - }, - Status::Translated(t) => t, - }) - .collect() - }, - None => { - translated_names - .map(|status| match status { - Status::Remaining(name) => OwnedTranslation(name), - Status::Translated(t) => t, - }) - .collect() - }, - }; - // sorted collection of human and machine names let mut human_names: Vec<(OwnedTranslation, LayoutId)> = translated_names .into_iter() diff --git a/src/style.rs b/src/style.rs index b12e756c..381dd045 100644 --- a/src/style.rs +++ b/src/style.rs @@ -16,7 +16,7 @@ * License along with this library. If not, see .Free */ -/*! CSS data loading */ +/*! CSS data loading. */ use std::env; @@ -83,6 +83,7 @@ fn get_theme_name(settings: >k::Settings) -> GtkTheme { .map_err(|e| { match &e { env::VarError::NotPresent => {}, + // maybe TODO: forward this warning? e => eprintln!("GTK_THEME variable invalid: {}", e), }; e @@ -93,13 +94,15 @@ fn get_theme_name(settings: >k::Settings) -> GtkTheme { None => GtkTheme { name: { settings.get_property("gtk-theme-name") - .ok_warn("No theme name") + // maybe TODO: is this worth a warning? + .or_warn("No theme name") .and_then(|value| value.get::()) .unwrap_or(DEFAULT_THEME_NAME.into()) }, variant: { settings.get_property("gtk-application-prefer-dark-theme") - .ok_warn("No settings key") + // maybe TODO: is this worth a warning? + .or_warn("No settings key") .and_then(|value| value.get::()) .and_then(|dark_preferred| match dark_preferred { true => Some("dark".into()), diff --git a/src/util.rs b/src/util.rs index 55a4373f..d58a3e77 100644 --- a/src/util.rs +++ b/src/util.rs @@ -190,6 +190,11 @@ impl Borrow> for Pointer { } } +pub trait WarningHandler { + /// Handle a warning + fn handle(&mut self, warning: &str); +} + #[cfg(test)] mod tests { use super::*; From 1924a8e6348d7f07dc6b3f2653bc3e0e0552f264 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 8 Jan 2020 11:52:42 +0000 Subject: [PATCH 03/15] v1.6.0: Fix suite --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 0808bcfb..37081853 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -squeekboard (1.6.0) UNRELEASED; urgency=medium +squeekboard (1.6.0) amber-phone; urgency=medium [ Dorota Czaplejewicz ] * tools: Move entry.py From e06e23dd4c5ce4e727701ce8580f28834eddae64 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 8 Jan 2020 12:06:15 +0000 Subject: [PATCH 04/15] overlay: Add terminal Enables Terminal to be selected as an overlay over the selected language. --- src/resources.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/resources.rs b/src/resources.rs index b17b0ef5..ea34d52d 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -11,6 +11,7 @@ use std::iter::FromIterator; // and what a convenience layout. "_wide" is not a layout, // neither is "number" const KEYBOARDS: &[(*const str, *const str)] = &[ + // layouts ("us", include_str!("../data/keyboards/us.yaml")), ("us_wide", include_str!("../data/keyboards/us_wide.yaml")), ("de", include_str!("../data/keyboards/de.yaml")), @@ -24,6 +25,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("no", include_str!("../data/keyboards/no.yaml")), ("number", include_str!("../data/keyboards/number.yaml")), ("se", include_str!("../data/keyboards/se.yaml")), + // layout+overlay ("terminal", include_str!("../data/keyboards/terminal.yaml")), // Overlays ("emoji", include_str!("../data/keyboards/emoji.yaml")), @@ -44,7 +46,8 @@ pub fn get_keyboard(needle: &str) -> Option<&'static str> { } const OVERLAY_NAMES: &[*const str] = &[ - "emoji" + "emoji", + "terminal", ]; pub fn get_overlays() -> Vec<&'static str> { From d80cbf880f0524e310ba5b61a3466ac7bd7c5a84 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 8 Jan 2020 12:19:53 +0000 Subject: [PATCH 05/15] cargo: Refresh deps for release --- Cargo.lock | 122 +++++++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0794512..9aa6b212 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,16 +23,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "atty" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -50,7 +51,7 @@ dependencies = [ "glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -61,14 +62,14 @@ dependencies = [ "glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cc" -version = "1.0.45" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -77,7 +78,7 @@ version = "2.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -110,7 +111,7 @@ dependencies = [ "glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -125,7 +126,7 @@ dependencies = [ "glib 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -136,8 +137,8 @@ dependencies = [ "gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -150,9 +151,9 @@ dependencies = [ "gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -167,7 +168,7 @@ dependencies = [ "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -177,8 +178,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -190,7 +191,7 @@ dependencies = [ "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -198,8 +199,8 @@ name = "glib-sys" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -208,8 +209,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -220,7 +221,7 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-sys-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "gdk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-pixbuf 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-pixbuf-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +233,7 @@ dependencies = [ "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -248,9 +249,17 @@ dependencies = [ "gio-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hermit-abi" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -260,7 +269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.62" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -283,7 +292,7 @@ name = "memmap" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -297,7 +306,7 @@ dependencies = [ "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -308,18 +317,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pkg-config" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -330,7 +339,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -366,37 +375,37 @@ dependencies = [ "gtk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", "xkbcommon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde" -version = "1.0.101" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.101" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_yaml" -version = "0.8.9" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -407,10 +416,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "1.0.5" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -475,7 +484,7 @@ name = "xkbcommon" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -491,11 +500,11 @@ dependencies = [ "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum atk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7017e53393e713212aed7aea336b6553be4927f58c37070a56c2fe3d107e489" -"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd940f0d609699e343ef71c4af5f66423afbf30d666f796dabd8fd15229cf5b6" "checksum cairo-sys-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d25596627380be4381247dba06c69ad05ca21b3b065bd9827e416882ac41dcd2" -"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" +"checksum cc 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)" = "e450b8da92aa6f274e7c6437692f9f2ce6d701fb73bacfcf87897b3f89a4c20e" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" @@ -510,24 +519,25 @@ dependencies = [ "checksum gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08475e4a08f27e6e2287005950114735ed61cec2cb8c1187682a5aec8c69b715" "checksum gtk 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56a6b30f194f09a17bb7ffa95c3ecdb405abd3b75ff981f831b1f6d18fe115ff" "checksum gtk-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d487d333a4b87072e6bf9f2e55befa0ebef01b9496c2e263c0f4a1ff3d6c04b1" +"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" "checksum pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c2cb169402a3eb1ba034a7cc7d95b8b1c106e9be5ba4be79a5a93dc1a2795f4" "checksum pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6eb49268e69dd0c1da5d3001a61aac08e2e9d2bfbe4ae4b19b9963c998f6453" -"checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" -"checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc" +"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" +"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" -"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" -"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" -"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" +"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" From 273423f6268087a5931626fdef07a5616ae0df43 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 8 Jan 2020 11:57:07 +0000 Subject: [PATCH 06/15] Release 1.7.0 "Mycelium" Enables a terminal layout, which will activate whenever the terminal input hint is received. Arm64 .debs are produced by the CI again. --- debian/changelog | 6 ++++++ meson.build | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 37081853..22f09941 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +squeekboard (1.7.0) amber-phone; urgency=medium + + * New terminal layout appearing on terminal input hint + + -- Dorota Czaplejewicz Wed, 08 Jan 2020 11:53:07 +0000 + squeekboard (1.6.0) amber-phone; urgency=medium [ Dorota Czaplejewicz ] diff --git a/meson.build b/meson.build index 9cbfc5f3..66340e09 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'squeekboard', 'c', 'rust', - version: '1.6.0', + version: '1.7.0', license: 'GPLv3', meson_version: '>=0.51.0', default_options: [ From 4e4f8e1932b81e26a7d68d57eebb06c40632b5fb Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 12 Jan 2020 19:25:09 +0000 Subject: [PATCH 07/15] eek-layout: Remove unused --- eek/eek-keyboard.h | 1 - eek/eek-layout.c | 47 ------------------------------------ eek/eek-layout.h | 60 ---------------------------------------------- eek/eek.h | 1 - src/meson.build | 1 - 5 files changed, 110 deletions(-) delete mode 100644 eek/eek-layout.c delete mode 100644 eek/eek-layout.h diff --git a/eek/eek-keyboard.h b/eek/eek-keyboard.h index ebf63351..9bc5e2e0 100644 --- a/eek/eek-keyboard.h +++ b/eek/eek-keyboard.h @@ -28,7 +28,6 @@ #include #include #include "eek-types.h" -#include "eek-layout.h" #include "src/layout.h" G_BEGIN_DECLS diff --git a/eek/eek-layout.c b/eek/eek-layout.c deleted file mode 100644 index ff4f96ca..00000000 --- a/eek/eek-layout.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2010-2011 Daiki Ueno - * Copyright (C) 2010-2011 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -/** - * SECTION:eek-layout - * @short_description: Base class of a layout engine - * - * The #EekLayout class is a base class of layout engine which - * arranges keyboard elements. - */ - -#include "config.h" - -#include "eek-layout.h" -#include "eek-keyboard.h" -#include "eekboard/eekboard-context-service.h" -#include "eek-xml-layout.h" - -G_DEFINE_ABSTRACT_TYPE (EekLayout, eek_layout, G_TYPE_OBJECT) - -static void -eek_layout_class_init (EekLayoutClass *klass) -{ - klass->create_keyboard = NULL; -} - -void -eek_layout_init (EekLayout *self) -{ -} diff --git a/eek/eek-layout.h b/eek/eek-layout.h deleted file mode 100644 index 480f1692..00000000 --- a/eek/eek-layout.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2010-2011 Daiki Ueno - * Copyright (C) 2010-2011 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#if !defined(__EEK_H_INSIDE__) && !defined(EEK_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef EEK_LAYOUT_H -#define EEK_LAYOUT_H 1 - -#include -#include "eek-types.h" -#include "src/layout.h" - -G_BEGIN_DECLS - -#define EEK_TYPE_LAYOUT (eek_layout_get_type()) -G_DECLARE_DERIVABLE_TYPE (EekLayout, eek_layout, EEK, LAYOUT, GObject) - -/** - * EekLayoutClass: - * @create_keyboard: virtual function for creating a keyboard - */ -struct _EekLayoutClass -{ - /*< private >*/ - GObjectClass parent_class; - - /*< public >*/ - LevelKeyboard* (* create_keyboard) (EekboardContextService *manager, - EekLayout *self, - gdouble initial_width, - gdouble initial_height); - - /*< private >*/ - /* padding */ - gpointer pdummy[24]; -}; - -GType eek_layout_get_type (void) G_GNUC_CONST; - -G_END_DECLS -#endif /* EEK_LAYOUT_H */ diff --git a/eek/eek.h b/eek/eek.h index c1548121..5ba3d099 100644 --- a/eek/eek.h +++ b/eek/eek.h @@ -23,7 +23,6 @@ #define __EEK_H_INSIDE__ 1 #include "eek-keyboard.h" -#include "eek-layout.h" void eek_init (void); diff --git a/src/meson.build b/src/meson.build index 9763f647..ef317d37 100644 --- a/src/meson.build +++ b/src/meson.build @@ -19,7 +19,6 @@ sources = [ '../eek/eek-element.c', '../eek/eek-gtk-keyboard.c', '../eek/eek-keyboard.c', - '../eek/eek-layout.c', '../eek/eek-renderer.c', '../eek/eek-types.c', '../eek/eek-xml-layout.c', From a78f8e246b0758af2aadc35e3316cf72d7ed9d5d Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Tue, 14 Jan 2020 13:54:10 +0000 Subject: [PATCH 08/15] pre-release: Update deps --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9aa6b212..63ac9f86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ name = "aho-corasick" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -69,7 +69,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -221,7 +221,7 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-sys-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", "gdk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-pixbuf 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-pixbuf-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -284,7 +284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memchr" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -348,15 +348,15 @@ version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.12" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -504,7 +504,7 @@ dependencies = [ "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum cairo-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd940f0d609699e343ef71c4af5f66423afbf30d666f796dabd8fd15229cf5b6" "checksum cairo-sys-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d25596627380be4381247dba06c69ad05ca21b3b065bd9827e416882ac41dcd2" -"checksum cc 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)" = "e450b8da92aa6f274e7c6437692f9f2ce6d701fb73bacfcf87897b3f89a4c20e" +"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9" @@ -524,7 +524,7 @@ dependencies = [ "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" "checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" "checksum pango 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c2cb169402a3eb1ba034a7cc7d95b8b1c106e9be5ba4be79a5a93dc1a2795f4" "checksum pango-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6eb49268e69dd0c1da5d3001a61aac08e2e9d2bfbe4ae4b19b9963c998f6453" @@ -532,7 +532,7 @@ dependencies = [ "checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" -"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" +"checksum regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90" "checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" From dca0e55557d75151790cb974ae45839f8627d815 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Tue, 14 Jan 2020 13:56:21 +0000 Subject: [PATCH 09/15] Release 1.8.0 "Conflict-free replicated data type" - The terminal layout is always available from the layout selection popup. - XKB Layout names in the popup are translated using GNOME's database. --- debian/changelog | 17 +++++++++++++++++ meson.build | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 22f09941..f2a51e4b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,20 @@ +squeekboard (1.8.0) amber-phone; urgency=medium + + [ Dorota Czaplejewicz ] + * translations: Use gnome-desktop's xkb info database for layout names + * translations: Make the code cleaner + * overlay: Add terminal + * eek-layout: Remove unused + * pre-release: Update deps + + -- Dorota Czaplejewicz Tue, 14 Jan 2020 13:55:00 +0000 + +squeekboard (1.7.0) amber-phone; urgency=medium + + * New terminal layout appearing on terminal input hint + + -- Dorota Czaplejewicz Wed, 08 Jan 2020 11:53:07 +0000 + squeekboard (1.7.0) amber-phone; urgency=medium * New terminal layout appearing on terminal input hint diff --git a/meson.build b/meson.build index 66340e09..d33b76a1 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'squeekboard', 'c', 'rust', - version: '1.7.0', + version: '1.8.0', license: 'GPLv3', meson_version: '>=0.51.0', default_options: [ From 60c68dbf5a7515fa2c2fa442f83c97171eba4be4 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Tue, 14 Jan 2020 18:47:04 +0000 Subject: [PATCH 10/15] ci: Clean up `..` before it's searched for artifacts GitLab doesn't always clean up the `..` directory, leaving things that are lated picked up as artifacts. The new rule cleans up anything that looks like an artifact before fresh ones are generated. --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 63d572e4..d8fdf579 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,7 @@ build_deb: paths: - "*.deb" script: + - rm -f ../*.deb - apt-get -y build-dep . - apt-get -y install devscripts - debuild -i -us -uc -b @@ -59,6 +60,7 @@ build_deb:arm64: paths: - "*.deb" script: + - rm -f ../*.deb - apt-get -y build-dep . - apt-get -y install devscripts - debuild -i -us -uc -b From 81e0c15db92ac8af8f83b920a2369ffe1b3e0f03 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 15 Jan 2020 17:06:00 +0000 Subject: [PATCH 11/15] dbus: Log error on dbus exit --- src/server-main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/server-main.c b/src/server-main.c index 56a2fd1f..35377e17 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -64,9 +64,11 @@ on_name_lost (GDBusConnection *connection, gpointer user_data) { // TODO: could conceivable continue working + // if intrnal changes stop sending dbus changes (void)connection; (void)name; (void)user_data; + g_error("DBus unavailable, unclear how to continue."); exit (1); } From ea84f4f0310a95e2ea9b3ab1fc2c5586a7a25abe Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 16 Jan 2020 15:57:46 +0000 Subject: [PATCH 12/15] logging: Try to improve common operations This adds sugar for logging `Result`s with a handler, makes names evoke something closer to "logging" than "warning", tries to remove any redundant `Logging` where the module name will do, and introduces a type strictly for bad things happening. --- src/data.rs | 106 ++++++++++++++++++++++---------------------- src/logging.rs | 117 +++++++++++++++++++++++++++++++++++++++---------- src/popover.rs | 8 +++- src/style.rs | 7 ++- src/tests.rs | 19 +++++--- 5 files changed, 168 insertions(+), 89 deletions(-) diff --git a/src/data.rs b/src/data.rs index 0fa30751..bd32ed88 100644 --- a/src/data.rs +++ b/src/data.rs @@ -21,7 +21,7 @@ use ::keyboard::{ }; use ::layout; use ::layout::ArrangementKind; -use ::logging::PrintWarnings; +use ::logging; use ::resources; use ::util::c::as_str; use ::util::hash_map_map; @@ -31,7 +31,7 @@ use ::xdg; use serde::Deserialize; use std::io::BufReader; use std::iter::FromIterator; -use ::logging::WarningHandler; +use ::logging::Warn; /// Gathers stuff defined in C or called by C pub mod c { @@ -157,7 +157,7 @@ fn list_layout_sources( fn load_layout_data(source: DataSource) -> Result<::layout::LayoutData, LoadError> { - let handler = PrintWarnings{}; + let handler = logging::Print {}; match source { DataSource::File(path) => { Layout::from_file(path.clone()) @@ -330,7 +330,7 @@ impl Layout { serde_yaml::from_reader(infile).map_err(Error::Yaml) } - pub fn build(self, mut warning_handler: H) + pub fn build(self, mut warning_handler: H) -> (Result<::layout::LayoutData, FormattingError>, H) { let button_names = self.views.values() @@ -464,7 +464,7 @@ impl Layout { } } -fn create_action( +fn create_action( button_info: &HashMap, name: &str, view_names: Vec<&String>, @@ -494,15 +494,18 @@ fn create_action( (None, None, Some(text)) => SubmitData::Text(text.clone()), (None, None, None) => SubmitData::Text(name.into()), _ => { - warning_handler.handle(&format!( - "Button {} has more than one of (action, keysym, text)", - name - )); + warning_handler.handle( + logging::Level::Warning, + &format!( + "Button {} has more than one of (action, keysym, text)", + name, + ), + ); SubmitData::Text("".into()) }, }; - fn filter_view_name( + fn filter_view_name( button_name: &str, view_name: String, view_names: &Vec<&String>, @@ -511,10 +514,13 @@ fn create_action( if view_names.contains(&&view_name) { view_name } else { - warning_handler.handle(&format!("Button {} switches to missing view {}", - button_name, - view_name, - )); + warning_handler.handle( + logging::Level::Warning, + &format!("Button {} switches to missing view {}", + button_name, + view_name, + ), + ); "base".into() } } @@ -553,27 +559,24 @@ fn create_action( match keysym_valid(keysym.as_str()) { true => keysym.clone(), false => { - warning_handler.handle(&format!( - "Keysym name invalid: {}", - keysym, - )); + warning_handler.handle( + logging::Level::Warning, + &format!( + "Keysym name invalid: {}", + keysym, + ), + ); "space".into() // placeholder }, } )), }, SubmitData::Text(text) => ::action::Action::Submit { - text: { - CString::new(text.clone()) - .map_err(|e| { - warning_handler.handle(&format!( - "Text {} contains problems: {:?}", - text, - e - )); - e - }).ok() - }, + text: CString::new(text.clone()).or_warn( + warning_handler, + logging::Problem::Warning, + &format!("Text {} contains problems", text), + ), keys: text.chars().map(|codepoint| { let codepoint_string = codepoint.to_string(); ::action::KeySym(match keysym_valid(codepoint_string.as_str()) { @@ -587,7 +590,7 @@ fn create_action( /// TODO: Since this will receive user-provided data, /// all .expect() on them should be turned into soft fails -fn create_button( +fn create_button( button_info: &HashMap, outlines: &HashMap, name: &str, @@ -611,14 +614,11 @@ fn create_button( } else if let Some(text) = &button_meta.text { ::layout::Label::Text( CString::new(text.as_str()) - .unwrap_or_else(|e| { - warning_handler.handle(&format!( - "Text {} is invalid: {}", - text, - e, - )); - CString::new("").unwrap() - }) + .or_warn( + warning_handler, + logging::Problem::Warning, + &format!("Text {} is invalid", text), + ).unwrap_or_else(|| CString::new("").unwrap()) ) } else { ::layout::Label::Text(cname.clone()) @@ -629,7 +629,10 @@ fn create_button( if outlines.contains_key(outline) { outline.clone() } else { - warning_handler.handle(&format!("Outline named {} does not exist! Using default for button {}", outline, name)); + warning_handler.handle( + logging::Level::Warning, + &format!("Outline named {} does not exist! Using default for button {}", outline, name) + ); "default".into() } } @@ -638,12 +641,11 @@ fn create_button( let outline = outlines.get(&outline_name) .map(|outline| (*outline).clone()) - .unwrap_or_else(|| { - warning_handler.handle( - &format!("No default outline defined! Using 1x1!") - ); - Outline { width: 1f64, height: 1f64 } - }); + .or_warn( + warning_handler, + logging::Problem::Warning, + "No default outline defined! Using 1x1!", + ).unwrap_or(Outline { width: 1f64, height: 1f64 }); layout::Button { name: cname, @@ -663,7 +665,7 @@ mod tests { use super::*; use std::error::Error as ErrorTrait; - use ::logging::PanicWarn; + use ::logging::ProblemPanic; #[test] fn test_parse_path() { @@ -733,7 +735,7 @@ mod tests { fn test_layout_punctuation() { let out = Layout::from_file(PathBuf::from("tests/layout_key1.yaml")) .unwrap() - .build(PanicWarn).0 + .build(ProblemPanic).0 .unwrap(); assert_eq!( out.views["base"] @@ -748,7 +750,7 @@ mod tests { fn test_layout_unicode() { let out = Layout::from_file(PathBuf::from("tests/layout_key2.yaml")) .unwrap() - .build(PanicWarn).0 + .build(ProblemPanic).0 .unwrap(); assert_eq!( out.views["base"] @@ -764,7 +766,7 @@ mod tests { fn test_layout_unicode_multi() { let out = Layout::from_file(PathBuf::from("tests/layout_key3.yaml")) .unwrap() - .build(PanicWarn).0 + .build(ProblemPanic).0 .unwrap(); assert_eq!( out.views["base"] @@ -779,7 +781,7 @@ mod tests { #[test] fn parsing_fallback() { assert!(Layout::from_resource(FALLBACK_LAYOUT_NAME) - .map(|layout| layout.build(PanicWarn).0.unwrap()) + .map(|layout| layout.build(ProblemPanic).0.unwrap()) .is_ok() ); } @@ -827,7 +829,7 @@ mod tests { }, ".", Vec::new(), - &mut PanicWarn, + &mut ProblemPanic, ), ::action::Action::Submit { text: Some(CString::new(".").unwrap()), @@ -840,7 +842,7 @@ mod tests { fn test_layout_margins() { let out = Layout::from_file(PathBuf::from("tests/layout_margins.yaml")) .unwrap() - .build(PanicWarn).0 + .build(ProblemPanic).0 .unwrap(); assert_eq!( out.margins, diff --git a/src/logging.rs b/src/logging.rs index 7beb9ff1..ba0ed2b8 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -26,13 +26,15 @@ * 4. logging to an immutable destination type * * Same as above, except it can be parallelized. + * Logs being outputs, they get returned + * instead of being misleadingly passed back through arguments. * It seems more difficult to pass the logger around, * but this may be a solved problem from the area of functional programming. * * This library generally aims at the approach in 3. * */ -use std::error::Error; +use std::fmt::Display; /// Levels are not in order. pub enum Level { @@ -66,18 +68,72 @@ pub enum Level { Debug, } -/// Sugar for logging errors in results. -/// Approach 2. -pub trait Warn { - type Value; - fn or_warn(self, msg: &str) -> Option; +impl Level { + fn as_str(&self) -> &'static str { + match self { + Level::Panic => "Panic", + Level::Bug => "Bug", + Level::Error => "Error", + Level::Warning => "Warning", + Level::Surprise => "Surprise", + Level::Info => "Info", + Level::Debug => "Debug", + } + } } -impl Warn for Result { +impl From for Level { + fn from(problem: Problem) -> Level { + use self::Level::*; + match problem { + Problem::Panic => Panic, + Problem::Bug => Bug, + Problem::Error => Error, + Problem::Warning => Warning, + Problem::Surprise => Surprise, + } + } +} + +/// Only levels which indicate problems +/// To use with `Result::Err` handlers, +/// which are needed only when something went off the optimal path. +/// A separate type ensures that `Err` +/// can't end up misclassified as a benign event like `Info`. +pub enum Problem { + Panic, + Bug, + Error, + Warning, + Surprise, +} + +/// Sugar for logging errors in results. +pub trait Warn where Self: Sized{ + type Value; + /// Approach 2. + fn or_print(self, level: Problem, message: &str) -> Option { + self.or_warn(&mut Print {}, level.into(), message) + } + /// Approach 3. + fn or_warn( + self, + handler: &mut H, + level: Problem, + message: &str, + ) -> Option; +} + +impl Warn for Result { type Value = T; - fn or_warn(self, msg: &str) -> Option { + fn or_warn( + self, + handler: &mut H, + level: Problem, + message: &str, + ) -> Option { self.map_err(|e| { - eprintln!("{}: {}", msg, e); + handler.handle(level.into(), &format!("{}: {}", message, e)); e }).ok() } @@ -85,9 +141,14 @@ impl Warn for Result { impl Warn for Option { type Value = T; - fn or_warn(self, msg: &str) -> Option { + fn or_warn( + self, + handler: &mut H, + level: Problem, + message: &str, + ) -> Option { self.or_else(|| { - eprintln!("{}", msg); + handler.handle(level.into(), message); None }) } @@ -95,26 +156,34 @@ impl Warn for Option { /// A mutable handler for text warnings. /// Approach 3. -pub trait WarningHandler { - /// Handle a warning - fn handle(&mut self, warning: &str); +pub trait Handler { + /// Handle a log message + fn handle(&mut self, level: Level, message: &str); } -/// Prints warnings to stderr -pub struct PrintWarnings; +/// Prints info to stdout, everything else to stderr +pub struct Print; -impl WarningHandler for PrintWarnings { - fn handle(&mut self, warning: &str) { - eprintln!("{}", warning); +impl Handler for Print { + fn handle(&mut self, level: Level, message: &str) { + match level { + Level::Info => println!("Info: {}", message), + l => eprintln!("{}: {}", l.as_str(), message), + } } } -/// Warning handler that will panic at any warning. +/// Warning handler that will panic +/// at any warning, error, surprise, bug, or panic. /// Don't use except in tests -pub struct PanicWarn; +pub struct ProblemPanic; -impl WarningHandler for PanicWarn { - fn handle(&mut self, warning: &str) { - panic!("{}", warning); +impl Handler for ProblemPanic { + fn handle(&mut self, level: Level, message: &str) { + use self::Level::*; + match level { + Panic | Bug | Error | Warning | Surprise => panic!("{}", message), + l => Print{}.handle(l, message), + } } } diff --git a/src/popover.rs b/src/popover.rs index c0b53086..6132b4ab 100644 --- a/src/popover.rs +++ b/src/popover.rs @@ -7,6 +7,7 @@ use ::layout::c::{ Bounds, EekGtkKeyboard }; use ::locale; use ::locale::{ OwnedTranslation, Translation, compare_current_locale }; use ::locale_config::system_locale; +use ::logging; use ::manager; use ::resources; @@ -242,10 +243,13 @@ fn translate_layout_names(layouts: &Vec) -> Vec { .as_ref() .to_owned() ) - .or_warn("No locale detected") + .or_print(logging::Problem::Surprise, "No locale detected") .and_then(|lang| { resources::get_layout_names(lang.as_str()) - .or_warn(&format!("No translations for locale {}", lang)) + .or_print( + logging::Problem::Surprise, + &format!("No translations for locale {}", lang), + ) }); match builtin_translations { diff --git a/src/style.rs b/src/style.rs index 381dd045..2e033a7e 100644 --- a/src/style.rs +++ b/src/style.rs @@ -19,6 +19,7 @@ /*! CSS data loading. */ use std::env; +use ::logging; use glib::object::ObjectExt; use logging::Warn; @@ -94,15 +95,13 @@ fn get_theme_name(settings: >k::Settings) -> GtkTheme { None => GtkTheme { name: { settings.get_property("gtk-theme-name") - // maybe TODO: is this worth a warning? - .or_warn("No theme name") + .or_print(logging::Problem::Surprise, "No theme name") .and_then(|value| value.get::()) .unwrap_or(DEFAULT_THEME_NAME.into()) }, variant: { settings.get_property("gtk-application-prefer-dark-theme") - // maybe TODO: is this worth a warning? - .or_warn("No settings key") + .or_print(logging::Problem::Surprise, "No settings key") .and_then(|value| value.get::()) .and_then(|dark_preferred| match dark_preferred { true => Some("dark".into()), diff --git a/src/tests.rs b/src/tests.rs index 3de54ccf..568fe29a 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,17 +1,22 @@ /*! Testing functionality */ use ::data::Layout; +use ::logging; use xkbcommon::xkb; -use ::logging::WarningHandler; - pub struct CountAndPrint(u32); -impl WarningHandler for CountAndPrint { - fn handle(&mut self, warning: &str) { - self.0 = self.0 + 1; - println!("{}", warning); +impl logging::Handler for CountAndPrint { + fn handle(&mut self, level: logging::Level, warning: &str) { + use logging::Level::*; + match level { + Panic | Bug | Error | Warning | Surprise => { + self.0 += 1; + }, + _ => {} + } + logging::Print{}.handle(level, warning) } } @@ -34,7 +39,7 @@ fn check_layout(layout: Layout) { let (layout, handler) = layout.build(handler); if handler.0 > 0 { - println!("{} mistakes in layout", handler.0) + println!("{} problems while parsing layout", handler.0) } let layout = layout.expect("layout broken"); From cc418c36095bb3edbd62a022467f99bbb3b12737 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Fri, 17 Jan 2020 11:59:47 +0000 Subject: [PATCH 13/15] imservice: Return something more resembling an Error on failure The error type is expected to be printable by logging utilities. --- src/imservice.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/imservice.rs b/src/imservice.rs index d3e4c5d0..2f39476a 100644 --- a/src/imservice.rs +++ b/src/imservice.rs @@ -1,5 +1,6 @@ use std::boxed::Box; use std::ffi::CString; +use std::fmt; use std::num::Wrapping; use std::string::String; @@ -246,10 +247,17 @@ pub enum ContentPurpose { Terminal = 13, } +// Utilities from ::logging need a printable error type +pub struct UnrecognizedValue; + +impl fmt::Display for UnrecognizedValue { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Unrecognized value") + } +} + impl TryFrom for ContentPurpose { - // There's only one way to fail: number not in protocol, - // so no special error type is needed - type Error = (); + type Error = UnrecognizedValue; fn try_from(num: u32) -> Result { use self::ContentPurpose::*; match num { @@ -267,7 +275,7 @@ impl TryFrom for ContentPurpose { 11 => Ok(Time), 12 => Ok(Datetime), 13 => Ok(Terminal), - _ => Err(()), + _ => Err(UnrecognizedValue), } } } @@ -280,14 +288,12 @@ pub enum ChangeCause { } impl TryFrom for ChangeCause { - // There's only one way to fail: number not in protocol, - // so no special error type is needed - type Error = (); + type Error = UnrecognizedValue; fn try_from(num: u32) -> Result { match num { 0 => Ok(ChangeCause::InputMethod), 1 => Ok(ChangeCause::Other), - _ => Err(()) + _ => Err(UnrecognizedValue) } } } From c75e085dc8e1dc1755316b0568ab7451ad1c8488 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Fri, 17 Jan 2020 12:25:39 +0000 Subject: [PATCH 14/15] logging: Unified to remove random eprint calls --- src/data.rs | 6 ++++-- src/imservice.rs | 32 ++++++++++++++++++------------ src/keyboard.rs | 8 +++++++- src/layout.rs | 34 ++++++++++++++++++++++++-------- src/lib.rs | 4 +++- src/locale.rs | 7 +++++++ src/logging.rs | 14 ++++++++++++- src/outputs.rs | 51 ++++++++++++++++++++++++++++++++---------------- src/popover.rs | 25 ++++++++++++------------ src/style.rs | 5 ++++- 10 files changed, 130 insertions(+), 56 deletions(-) diff --git a/src/data.rs b/src/data.rs index bd32ed88..c190e54f 100644 --- a/src/data.rs +++ b/src/data.rs @@ -190,11 +190,13 @@ fn load_layout_data_with_fallback( ( LoadError::BadData(Error::Missing(e)), DataSource::File(file) - ) => eprintln!( // TODO: print in debug logging level + ) => log_print!( + logging::Level::Debug, "Tried file {:?}, but it's missing: {}", file, e ), - (e, source) => eprintln!( + (e, source) => log_print!( + logging::Level::Warning, "Failed to load layout from {}: {}, skipping", source, e ), diff --git a/src/imservice.rs b/src/imservice.rs index 2f39476a..d29c45a8 100644 --- a/src/imservice.rs +++ b/src/imservice.rs @@ -4,10 +4,12 @@ use std::fmt; use std::num::Wrapping; use std::string::String; +use ::logging; use ::util::c::into_cstring; // Traits use std::convert::TryFrom; +use ::logging::Warn; /// Gathers stuff defined in C or called by C @@ -102,16 +104,20 @@ pub mod c { let imservice = check_imservice(imservice, im).unwrap(); imservice.pending = IMProtocolState { content_hint: { - ContentHint::from_bits(hint).unwrap_or_else(|| { - eprintln!("Warning: received invalid hint flags"); - ContentHint::NONE - }) + ContentHint::from_bits(hint) + .or_print( + logging::Problem::Warning, + "Received invalid hint flags", + ) + .unwrap_or(ContentHint::NONE) }, content_purpose: { - ContentPurpose::try_from(purpose).unwrap_or_else(|_e| { - eprintln!("Warning: Received invalid purpose value"); - ContentPurpose::Normal - }) + ContentPurpose::try_from(purpose) + .or_print( + logging::Problem::Warning, + "Received invalid purpose value", + ) + .unwrap_or(ContentPurpose::Normal) }, ..imservice.pending.clone() }; @@ -126,10 +132,12 @@ pub mod c { let imservice = check_imservice(imservice, im).unwrap(); imservice.pending = IMProtocolState { text_change_cause: { - ChangeCause::try_from(cause).unwrap_or_else(|_e| { - eprintln!("Warning: received invalid cause value"); - ChangeCause::InputMethod - }) + ChangeCause::try_from(cause) + .or_print( + logging::Problem::Warning, + "Received invalid cause value", + ) + .unwrap_or(ChangeCause::InputMethod) }, ..imservice.pending.clone() }; diff --git a/src/keyboard.rs b/src/keyboard.rs index 79cd36c4..bff1ac16 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -7,6 +7,7 @@ use std::io; use std::string::FromUtf8Error; use ::action::Action; +use ::logging; use std::io::Write; use std::iter::{ FromIterator, IntoIterator }; @@ -110,7 +111,12 @@ pub fn generate_keymap( for (name, state) in keystates.iter() { if let Action::Submit { text: _, keys } = &state.action { - if let 0 = keys.len() { eprintln!("Key {} has no keysyms", name); }; + if let 0 = keys.len() { + log_print!( + logging::Level::Warning, + "Key {} has no keysyms", name, + ); + }; for (named_keysym, keycode) in keys.iter().zip(&state.keycodes) { write!( buf, diff --git a/src/layout.rs b/src/layout.rs index 76f830c1..057f7674 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -20,17 +20,21 @@ use std::cell::RefCell; use std::collections::{ HashMap, HashSet }; use std::ffi::CString; +use std::fmt; use std::rc::Rc; use std::vec::Vec; use ::action::Action; use ::drawing; use ::keyboard::{ KeyState, PressType }; +use ::logging; use ::manager; use ::submission::{ Timestamp, VirtualKeyboard }; use ::util::find_max_double; +// Traits use std::borrow::Borrow; +use ::logging::Warn; /// Gathers stuff defined in C or called by C pub mod c { @@ -623,6 +627,12 @@ pub struct LayoutData { #[derive(Debug)] struct NoSuchView; +impl fmt::Display for NoSuchView { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "No such view") + } +} + // Unfortunately, changes are not atomic due to mutability :( // An error will not be recoverable // The usage of &mut on Rc> doesn't mean anything special. @@ -660,7 +670,10 @@ impl Layout { time: Timestamp, ) { if !self.pressed_keys.insert(::util::Pointer(rckey.clone())) { - eprintln!("Warning: key {:?} was already pressed", rckey); + log_print!( + logging::Level::Bug, + "Key {:?} was already pressed", rckey, + ); } let mut key = rckey.borrow_mut(); virtual_keyboard.switch( @@ -806,9 +819,10 @@ mod seat { fn try_set_view(layout: &mut Layout, view_name: String) { layout.set_view(view_name.clone()) - .map_err(|e| - eprintln!("Bad view {} ({:?}), ignoring", view_name, e) - ).ok(); + .or_print( + logging::Problem::Bug, + &format!("Bad view {}, ignoring", view_name), + ); } /// A vessel holding an obligation to switch view. @@ -850,9 +864,10 @@ mod seat { Action::LockView { lock: _, unlock: view } => { new_view = Some(view.clone()); }, - a => eprintln!( - "BUG: action {:?} was found inside locked keys", - a + a => log_print!( + logging::Level::Bug, + "Non-locking action {:?} was found inside locked keys", + a, ), }; key.locked = false; @@ -937,7 +952,10 @@ mod seat { } } }, - Action::SetModifier(_) => eprintln!("Modifiers unsupported"), + Action::SetModifier(_) => log_print!( + logging::Level::Bug, + "Modifiers unsupported", + ), }; let pointer = ::util::Pointer(rckey.clone()); diff --git a/src/lib.rs b/src/lib.rs index 7f422c6a..579ec478 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,6 +15,9 @@ extern crate regex; extern crate serde; extern crate xkbcommon; +#[macro_use] +mod logging; + mod action; pub mod data; mod drawing; @@ -24,7 +27,6 @@ mod keyboard; mod layout; mod locale; mod locale_config; -mod logging; mod manager; mod outputs; mod popover; diff --git a/src/locale.rs b/src/locale.rs index 6b87f68c..03e6bd9c 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -8,6 +8,7 @@ use std::cmp; use std::ffi::{ CStr, CString }; +use std::fmt; use std::os::raw::c_char; use std::ptr; use std::str::Utf8Error; @@ -47,6 +48,12 @@ pub enum Error { NoInfo, } +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self, f) + } +} + pub struct XkbInfo(c::GnomeXkbInfo); impl XkbInfo { diff --git a/src/logging.rs b/src/logging.rs index ba0ed2b8..7864d2a7 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -108,8 +108,20 @@ pub enum Problem { Surprise, } +/// Sugar for approach 2 +// TODO: avoid, deprecate. +// Handler instances should be long lived, not one per call. +macro_rules! log_print { + ($level:expr, $($arg:tt)*) => (::logging::print($level, &format!($($arg)*))) +} + +/// Approach 2 +pub fn print(level: Level, message: &str) { + Print{}.handle(level, message) +} + /// Sugar for logging errors in results. -pub trait Warn where Self: Sized{ +pub trait Warn where Self: Sized { type Value; /// Approach 2. fn or_print(self, level: Problem, message: &str) -> Option { diff --git a/src/outputs.rs b/src/outputs.rs index 9692e954..08ac590d 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -1,7 +1,10 @@ /*! Managing Wayland outputs */ use std::vec::Vec; +use ::logging; +// traits +use ::logging::Warn; /// Gathers stuff defined in C or called by C pub mod c { @@ -113,14 +116,11 @@ pub mod c { _make: *const c_char, _model: *const c_char, transform: i32, ) { - let transform = Transform::from_u32(transform as u32).unwrap_or_else( - || { - eprintln!( - "Warning: received invalid wl_output.transform value" - ); - Transform::Normal - } - ); + let transform = Transform::from_u32(transform as u32) + .or_print( + logging::Problem::Warning, + "Received invalid wl_output.transform value", + ).unwrap_or(Transform::Normal); let outputs = outputs.clone_ref(); let mut collection = outputs.borrow_mut(); @@ -129,7 +129,10 @@ pub mod c { .map(|o| &mut o.pending); match output_state { Some(state) => { state.transform = Some(transform) }, - None => eprintln!("Wayland error: Got mode on unknown output"), + None => log_print!( + logging::Level::Warning, + "Got geometry on unknown output", + ), }; } @@ -141,10 +144,12 @@ pub mod c { height: i32, _refresh: i32, ) { - let flags = Mode::from_bits(flags).unwrap_or_else(|| { - eprintln!("Warning: received invalid wl_output.mode flags"); - Mode::NONE - }); + let flags = Mode::from_bits(flags) + .or_print( + logging::Problem::Warning, + "Received invalid wl_output.mode flags", + ).unwrap_or(Mode::NONE); + let outputs = outputs.clone_ref(); let mut collection = outputs.borrow_mut(); let output_state: Option<&mut OutputState> @@ -156,7 +161,10 @@ pub mod c { state.current_mode = Some(super::Mode { width, height}); } }, - None => eprintln!("Wayland error: Got mode on unknown output"), + None => log_print!( + logging::Level::Warning, + "Got mode on unknown output", + ), }; } @@ -169,7 +177,10 @@ pub mod c { let output = find_output_mut(&mut collection, wl_output); match output { Some(output) => { output.current = output.pending.clone(); } - None => eprintln!("Wayland error: Got done on unknown output"), + None => log_print!( + logging::Level::Warning, + "Got done on unknown output", + ), }; } @@ -185,7 +196,10 @@ pub mod c { .map(|o| &mut o.pending); match output_state { Some(state) => { state.scale = factor; } - None => eprintln!("Wayland error: Got done on unknown output"), + None => log_print!( + logging::Level::Warning, + "Got scale on unknown output", + ), }; } @@ -258,7 +272,10 @@ pub mod c { } }, _ => { - eprintln!("Not enough info registered on output"); + log_print!( + logging::Level::Surprise, + "Not enough info received on output", + ); 0 }, } diff --git a/src/popover.rs b/src/popover.rs index 6132b4ab..5f0f735f 100644 --- a/src/popover.rs +++ b/src/popover.rs @@ -222,14 +222,10 @@ fn translate_layout_names(layouts: &Vec) -> Vec { LayoutId::System { name, kind: _ } => { xkb_translator.get_display_name(name) .map(|s| Status::Translated(OwnedTranslation(s))) - .unwrap_or_else(|e| { - eprintln!( - "No display name for xkb layout {}: {:?}", - name, - e, - ); - Status::Remaining(name.clone()) - }) + .or_print( + logging::Problem::Surprise, + &format!("No display name for xkb layout {}", name), + ).unwrap_or_else(|| Status::Remaining(name.clone())) }, LayoutId::Local(name) => Status::Remaining(name.clone()), }); @@ -365,10 +361,10 @@ pub fn show( match state { Some(v) => { v.get::() - .or_else(|| { - eprintln!("Variant is not string: {:?}", v); - None - }) + .or_print( + logging::Problem::Bug, + &format!("Variant is not string: {:?}", v) + ) .map(|state| { let (_id, layout) = choices.iter() .find( @@ -380,7 +376,10 @@ pub fn show( ) }); }, - None => eprintln!("No variant selected"), + None => log_print!( + logging::Level::Debug, + "No variant selected", + ), }; menu_inner.popdown(); }); diff --git a/src/style.rs b/src/style.rs index 2e033a7e..153431ae 100644 --- a/src/style.rs +++ b/src/style.rs @@ -85,7 +85,10 @@ fn get_theme_name(settings: >k::Settings) -> GtkTheme { match &e { env::VarError::NotPresent => {}, // maybe TODO: forward this warning? - e => eprintln!("GTK_THEME variable invalid: {}", e), + e => log_print!( + logging::Level::Surprise, + "GTK_THEME variable invalid: {}", e, + ), }; e }).ok(); From 2b65beba4492242b1fc6b189f92f4e3fc073470c Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 20 Jan 2020 15:40:30 +0000 Subject: [PATCH 15/15] press_key: Use proper logging --- src/layout.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layout.rs b/src/layout.rs index 6ef223ef..7682d8ec 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -871,7 +871,10 @@ mod seat { rckey: &Rc>, ) { if !layout.pressed_keys.insert(::util::Pointer(rckey.clone())) { - eprintln!("Warning: key {:?} was already pressed", rckey); + log_print!( + logging::Level::Bug, + "Key {:?} was already pressed", rckey, + ); } let mut key = rckey.borrow_mut(); virtual_keyboard.switch(