Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring keyboard with https://github.com/openSUSE/mentoring/issues/79 #225

Merged
merged 68 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
fc1ce42
refactoring with https://github.com/openSUSE/mentoring/issues/79
schubi2 Sep 12, 2019
f9e3c57
packaging
schubi2 Sep 13, 2019
8f2d6db
packaging
schubi2 Sep 13, 2019
91c3756
packaging
schubi2 Sep 13, 2019
a9d4cb9
packaging
schubi2 Sep 13, 2019
d8e18c5
packaging
schubi2 Sep 13, 2019
57ae54d
packaging
schubi2 Sep 13, 2019
23291f7
packaging
schubi2 Sep 13, 2019
343aae4
added path
schubi2 Sep 13, 2019
1cef2f6
testcases
schubi2 Sep 13, 2019
f44c278
default values
schubi2 Sep 13, 2019
a516f5c
improved layout
schubi2 Sep 13, 2019
48c8eb1
merged with master
schubi2 Sep 23, 2019
eb63d4e
cleanup; added general widget again because it is needed for installa…
schubi2 Sep 24, 2019
f58a9fa
replaces cheetah
schubi2 Sep 24, 2019
5515fbe
moved xkb/kbd calls in own strategy
schubi2 Sep 25, 2019
d3531be
moved xkb/kbd calls in own strategy
schubi2 Sep 25, 2019
324b3b8
using devices for loadkeys command
schubi2 Sep 25, 2019
af294d5
further cleanup
schubi2 Oct 1, 2019
66b61ec
code cleanup
schubi2 Oct 4, 2019
73653ee
testcases
schubi2 Oct 4, 2019
de33f57
fixed testcases
schubi2 Oct 4, 2019
245593d
fixed build
schubi2 Oct 4, 2019
ffbf068
build fixes
schubi2 Oct 4, 2019
a77d3dc
build fixes
schubi2 Oct 7, 2019
9a21d1d
fixed translation
schubi2 Oct 7, 2019
f158d2e
fixes for installed system
schubi2 Oct 7, 2019
dbf98cc
textdomain set
schubi2 Oct 7, 2019
b2780be
cleanup
schubi2 Oct 8, 2019
53b9842
fixed load
schubi2 Oct 8, 2019
f90f3d8
syntax error
schubi2 Oct 8, 2019
f0b2ea8
checking file at first
schubi2 Oct 8, 2019
ba2826f
syntax error
schubi2 Oct 8, 2019
2cb4799
added path
schubi2 Oct 8, 2019
b2475e5
set correct key code
schubi2 Oct 8, 2019
96c1f45
AY cleanup
schubi2 Oct 9, 2019
54c3316
AY cleanup
schubi2 Oct 9, 2019
35850ad
set testdomain
schubi2 Oct 9, 2019
c48dc10
removed old dialog
schubi2 Oct 9, 2019
ed4f990
initialize current keyboard
schubi2 Oct 9, 2019
5b84d08
initialize current keyboard
schubi2 Oct 9, 2019
90d0a6c
set right proposal
schubi2 Oct 10, 2019
89a9d76
proposal workflow
schubi2 Oct 10, 2019
0ec1530
bug fix
schubi2 Oct 10, 2019
5e6e021
docu
schubi2 Oct 11, 2019
55cb11d
cleanup proposal and AY
schubi2 Oct 11, 2019
04fd507
AY configuration
schubi2 Oct 11, 2019
2151d77
AY configuration
schubi2 Oct 14, 2019
82404ed
cleanup
schubi2 Oct 14, 2019
d75fdcc
command line call
schubi2 Oct 14, 2019
0a1de63
packaging
schubi2 Oct 14, 2019
a22b4d0
packaging
schubi2 Oct 14, 2019
ce5a41e
adapted testcases
schubi2 Oct 15, 2019
1fa90c6
fixed testcases
schubi2 Oct 15, 2019
b79c6c5
testsuite
schubi2 Oct 15, 2019
121165e
typo
schubi2 Oct 15, 2019
f292bea
added testcases
schubi2 Oct 16, 2019
042a15d
added testcases
schubi2 Oct 16, 2019
85e52c4
testcases
schubi2 Oct 17, 2019
1610758
testcases
schubi2 Oct 17, 2019
55eef9e
added testcases
schubi2 Oct 17, 2019
5fdf145
added testcases
schubi2 Oct 17, 2019
aa30ff3
fixed testcase in build
schubi2 Oct 17, 2019
011ecca
cleanup
schubi2 Oct 17, 2019
cdb9b41
adapted docu
schubi2 Oct 17, 2019
dc1da5d
merged with master
schubi2 Oct 21, 2019
f0610c7
suggested changes
schubi2 Oct 23, 2019
a5cde9f
suggested changes
schubi2 Oct 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 13 additions & 45 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,58 +44,26 @@ timezone) for YaST2.

---

- keyboard/src/data/keyboard_raw.ycp
- keyboard/src/data/keyboards.rb

Console keyboard layout
Array of keyboard layout

- key: yast_keyboard_id
- value: pair of translatable_string, more_data:
- key: keyboard_hardware (pc104, macintosh, type4, type5, type5_euro)
- value: more_data:
- ncurses: /usr/share/kbd/keymaps/xkb/%s
- compose: ? (optional)
- description: translatable string
- alias: yast keyboard id
- code: keymap
- suggested_for_lang: Languages which fits to this keyboard layout.

---

```js
"english-uk": [
_("English (UK)"),
$[
"pc104": $[ "ncurses": "gb.map.gz"],
"macintosh": $[ "ncurses": "gb-mac.map.gz" ],
"type4": $[ "ncurses": "us.map.gz"],
"type5": $[ "ncurses": "us.map.gz"],
"type5_euro": $[ "ncurses": "us.map.gz"],
]
[
{ "description" => _("English (US)"),
"alias" => "english-us",
"code" => "us",
"suggested_for_lang" => ["ar_eg", "en", "nl_BE"]
},
...
]

```

---

- keyboard/src/data/lang2keyboard.ycp (TODO convert)
- key: locale_id
- value: yast_keyboard_id

---

```js
"en_GB": "english-uk"
```

---

- keyboard/src/data/xkblayout2keyboard.ycp (TODO convert)

man xkeyboard-config

- key: xkblayout_id ?
- value: yast_keyboard_id

---

```js
"gb": "english-uk"
```

---
Expand Down
2 changes: 0 additions & 2 deletions keyboard/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#
# Makefile.am for country/keyboard
SUBDIRS = src
# TODO: test dir is not included as it is failing during obs build

38 changes: 25 additions & 13 deletions keyboard/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,14 @@ module_DATA = \
client_DATA = \
clients/keyboard_auto.rb \
clients/keyboard_proposal.rb \
clients/keyboard_simple_proposal.rb \
clients/keyboard.rb

yncludedir = @yncludedir@/keyboard
ynclude_DATA = \
include/keyboard/dialogs.rb

scrconf_DATA = \
scrconf/sysconfig_keyboard.scr \
scrconf/etc_vconsole_conf.scr

schemafilesdir = $(schemadir)/autoyast/rnc
schemafiles_DATA = \
autoyast-rnc/keyboard.rnc

ydata_DATA = \
data/keyboard_raw.ycp \
data/xkblayout2keyboard.ycp \
data/lang2keyboard.ycp
data/keyboards.rb

desktop_DATA = \
desktop/org.opensuse.yast.Keyboard.desktop
Expand All @@ -33,6 +22,27 @@ ywidgetsdir = @ylibdir@/y2country/widgets
ywidgets_DATA = \
lib/y2country/widgets/keyboard_selection.rb

ylibdir = @ylibdir@/y2keyboard
ylib_DATA = \
lib/y2keyboard/keyboard_layout_loader.rb \
lib/y2keyboard/keyboard_layout.rb

ylibclientsdir = @ylibdir@/y2keyboard/clients
ylibclients_DATA = \
lib/y2keyboard/clients/keyboard.rb \
lib/y2keyboard/clients/keyboard_proposal.rb \
lib/y2keyboard/clients/keyboard_auto.rb

ylibdialogsdir = @ylibdir@/y2keyboard/dialogs
ylibdialogs_DATA = \
lib/y2keyboard/dialogs/layout_selector.rb

ylibstrategiesdir = @ylibdir@/y2keyboard/strategies
ylibstrategies_DATA = \
lib/y2keyboard/strategies/systemd_strategy.rb \
lib/y2keyboard/strategies/kb_strategy.rb \
lib/y2keyboard/strategies/yast_proposal_strategy.rb

symbolicdir = @icondir@/hicolor/symbolic/apps
symbolic_DATA = \
icons/hicolor/symbolic/apps/yast-keyboard-symbolic.svg
Expand All @@ -41,6 +51,8 @@ scalable_DATA = \
icons/hicolor/scalable/apps/yast-keyboard.svg

EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) \
$(schemafiles_DATA) $(ydata_DATA) $(desktop_DATA) $(ywidgets_DATA) $(symbolic_DATA) $(scalable_DATA)
$(schemafiles_DATA) $(ydata_DATA) $(desktop_DATA) $(ywidgets_DATA) \
$(ylib_DATA) $(ylibclients_DATA) $(ylibdialogs_DATA) $(ylibstrategies_DATA) \
$(symbolic_DATA) $(scalable_DATA)

include $(top_srcdir)/Makefile.am.common
132 changes: 21 additions & 111 deletions keyboard/src/clients/keyboard.rb
Original file line number Diff line number Diff line change
@@ -1,64 +1,20 @@
# encoding: utf-8
require "yast"
require_relative "../lib/y2keyboard/clients/keyboard"

# ------------------------------------------------------------------------------
# Copyright (c) 2012 Novell, Inc. All Rights Reserved.
#
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of version 2 of the GNU General Public License as published by the
# Free Software Foundation.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail, you may find
# current contact information at www.novell.com.
# ------------------------------------------------------------------------------

#
# Module: keyboard.ycp
#
# Author: Thomas Roelz (tom@suse.de)
#
# Submodules:
#
#
# Purpose: configure keyboard in running system
#
# Modify:
#
#
# $Id$
module Yast
class KeyboardClient < Client
def main
Yast.import "UI"
textdomain "country"

Yast.import "Arch"
Yast.import "CommandLine"
Yast.import "Confirm"
Yast.import "Keyboard"
Yast.import "Popup"
Yast.import "Message"
Yast.import "Service"
Yast.import "Stage"
Yast.import "Wizard"

Yast.include self, "keyboard/dialogs.rb"


# -- the command line description map --------------------------------------
# The command line description map
@cmdline = {
"id" => "keyboard",
# translators: command line help text for Securoty module
"help" => _(
"Keyboard configuration."
),
# TRANSLATORS: command line help text for Securoty module
"help" => _("Keyboard configuration."),
"guihandler" => fun_ref(method(:KeyboardSequence), "any ()"),
"initialize" => fun_ref(method(:KeyboardRead), "boolean ()"),
"finish" => fun_ref(method(:KeyboardWrite), "boolean ()"),
Expand All @@ -69,66 +25,41 @@ def main
"boolean (map)"
),
# command line help text for 'summary' action
"help" => _(
"Keyboard configuration summary."
)
"help" => _("Keyboard configuration summary.")
},
"set" => {
"handler" => fun_ref(method(:KeyboardSetHandler), "boolean (map)"),
# command line help text for 'set' action
"help" => _(
"Set new values for keyboard configuration."
)
"help" => _("Set new values for keyboard configuration.")
},
"list" => {
"handler" => fun_ref(method(:KeyboardListHandler), "boolean (map)"),
# command line help text for 'list' action
"help" => _(
"List all available keyboard layouts."
)
"help" => _("List all available keyboard layouts.")
}
},
"options" => {
"layout" => {
# command line help text for 'set layout' option
"help" => _(
"New keyboard layout"
),
"help" => _("New keyboard layout"),
"type" => "string"
}
},
"mappings" => { "summary" => [], "set" => ["layout"], "list" => [] }
}

CommandLine.Run(@cmdline)
true
end

# read keyboard settings
def KeyboardRead
Keyboard.Read
# Check if this is a reconfiguration run.
#
if Stage.reprobe
# Reprobe keyboard module to achieve same behaviour as
# during installation.
Keyboard.Probe
Keyboard.SetConsole(Keyboard.current_kbd)
Keyboard.SetX11(Keyboard.current_kbd)

Builtins.y2milestone("Reprobed keyboard")
end
true
end

# write keyboard settings
def KeyboardWrite
if Keyboard.needs_new_initrd?
Popup.ShowFeedback(Message.updating_configuration, Message.takes_a_while)
end
Keyboard.Save
Service.Restart("kbd")
Popup.ClearFeedback if Keyboard.needs_new_initrd?
true
end

Expand All @@ -137,60 +68,39 @@ def KeyboardSequence
# dont ask for keyboard on S/390
return :next if Arch.s390

KeyboardRead()

Wizard.OpenOKDialog

result = KeyboardDialog({})

if result == :next
KeyboardWrite()
else
Builtins.y2milestone("User cancelled --> no change")
end
Wizard.CloseDialog
result
Y2Keyboard::Clients::Keyboard.run
end

# Handler for keyboard summary
def KeyboardSummaryHandler(options)
options = deep_copy(options)
# summary label
CommandLine.Print(
Builtins.sformat(_("Current Keyboard Layout: %1"), Keyboard.current_kbd)
)
CommandLine.Print(_("Current Keyboard Layout: %s" % Keyboard.current_kbd))
false
end

# Handler for listing keyboard layouts
def KeyboardListHandler(options)
options = deep_copy(options)
Builtins.foreach(Keyboard.Selection) do |code, name|
Keyboard.Selection.each do |code, name|
CommandLine.Print(Builtins.sformat("%1 (%2)", code, name))
end
false
end


# Handler for changing keyboard settings
def KeyboardSetHandler(options)
options = deep_copy(options)
keyboard = Ops.get_string(options, "layout", "")
keyboard = options["layout"] || ""

if keyboard == "" || !Builtins.haskey(Keyboard.Selection, keyboard)
# error message (%1 is given layout); do not translate 'list'
if keyboard == "" || !Keyboard.Selection.key?(keyboard)
# TRANSLATORS: error message (%1 is given layout); do not translate 'list'
CommandLine.Print(
Builtins.sformat(
_(
"Keyboard layout '%1' is invalid. Use a 'list' command to see possible values."
),
keyboard
)
_("Keyboard layout '%s' is invalid. Use a 'list' command to see possible values." % keyboard)
)
false
else
Keyboard.Set(keyboard)
Keyboard.Modified
true
end
Keyboard.Set(keyboard)

Keyboard.Modified
end
end
end
Expand Down
Loading